Merge all the 'assignment' diagnostic code into one routine, decloning 
it from several places.  This merges the diagnostics, making them more
uniform and fewer in number. This also simplifies and cleans up the code.

Some highlights:
1. This removes a bunch of very-similar diagnostics.
2. This renames AssignmentCheckResult -> AssignConvertType
3. This merges PointerFromInt + IntFromPointer which were always treated the same.
4. This updates a bunch of test cases that have minor changes to the produced diagnostics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45589 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/argument-checking.m b/test/Sema/argument-checking.m
index 57ab14f..cd84171 100644
--- a/test/Sema/argument-checking.m
+++ b/test/Sema/argument-checking.m
@@ -16,8 +16,8 @@
   id obj = [Test alloc];
   struct S sInst;
 
-  charStarFunc(1); // expected-warning {{incompatible types passing 'int' to function expecting 'char *'}}
-  charFunc("abc"); // expected-warning {{incompatible types passing 'char *' to function expecting 'char'}}
+  charStarFunc(1); // expected-warning {{incompatible pointer/int conversion passing 'int', expected 'char *'}}
+  charFunc("abc"); // expected-warning {{incompatible pointer/int conversion passing 'char *', expected 'char'}}
 
   [obj charStarMeth:1]; // expected-warning {{incompatible pointer/int conversion sending 'int'}}
   [obj structMeth:1]; // expected-error {{incompatible type sending 'int'}}
diff --git a/test/Sema/array-constraint.c b/test/Sema/array-constraint.c
index f281df1..df79681 100644
--- a/test/Sema/array-constraint.c
+++ b/test/Sema/array-constraint.c
@@ -45,7 +45,7 @@
 void strFunc(char *);
 const char staticAry[] = "test";
 int checkStaticAry() { 
-  strFunc(staticAry); // expected-warning{{passing 'char const [5]' to 'char *' discards qualifiers}}
+  strFunc(staticAry); // expected-warning{{passing 'char const [5]' discards qualifiers, expected 'char *'}}
 }
 
 
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c
index bf5ea06..1875fab 100644
--- a/test/Sema/array-init.c
+++ b/test/Sema/array-init.c
@@ -9,7 +9,7 @@
 
 extern int fileScopeExtern[3] = { 1, 3, 5 }; // expected-warning{{'extern' variable has an initializer}}
 
-static int ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible types assigning 'char *' to 'int'}}
+static int ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible pointer/int conversion initializing 'char *', expected 'int'}}
 
 void func() {
   int x = 1;
@@ -44,11 +44,11 @@
     int a,b,c;
   } z = { 1 };
 
-  struct threeElements *p = 7; // expected-warning{{incompatible types assigning 'int' to 'struct threeElements *'}}
+  struct threeElements *p = 7; // expected-warning{{incompatible pointer/int conversion initializing 'int', expected 'struct threeElements *'}}
   
   extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}}
   
-  static int x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible types assigning 'char *' to 'int'}}
+  static int x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible pointer/int conversion initializing 'char *', expected 'int'}}
 }
 
 void test() {
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index 997a8ed..59a339a 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -1,4 +1,4 @@
-// RUN: clang %s -fsyntax-only -verify
+// RUN: clang %s -fsyntax-only -verify -pedantic
 
 int test1(float a, int b) {
   return __builtin_isless(a, b);
@@ -26,8 +26,7 @@
 void cfstring() {
   CFSTR("\242"); // expected-warning {{ CFString literal contains non-ASCII character }}
   CFSTR("\0"); // expected-warning {{ CFString literal contains NUL character }}
-  CFSTR(242); // expected-error {{ CFString literal is not a string constant }} \
-    expected-warning {{incompatible types}}
+  CFSTR(242); // expected-error {{ CFString literal is not a string constant }} expected-warning {{incompatible pointer/int conversion}}
   CFSTR("foo", "bar"); // expected-error {{ error: too many arguments to function }}
 }
 
diff --git a/test/Sema/incompatible-protocol-qualified-types.m b/test/Sema/incompatible-protocol-qualified-types.m
index 417dcee..ad8c45e 100644
--- a/test/Sema/incompatible-protocol-qualified-types.m
+++ b/test/Sema/incompatible-protocol-qualified-types.m
@@ -21,7 +21,7 @@
 
 INTF <MyProto1, MyProto2> * Func2(INTF <MyProto1> *p2)
 {
-	Func(p2);	// expected-warning {{incompatible pointer types passing 'INTF<MyProto1> *' to function expecting 'INTF<MyProto1,MyProto2> *}}
+	Func(p2);	// expected-warning {{incompatible pointer types passing 'INTF<MyProto1> *', expected 'INTF<MyProto1,MyProto2> *}}
 	return p2;	// expected-warning {{incompatible pointer types returning 'INTF<MyProto1> *', expected 'INTF<MyProto1,MyProto2> *}}
 }
 
diff --git a/test/Sema/objc-comptypes-1.m b/test/Sema/objc-comptypes-1.m
index c4b457e..512565c 100644
--- a/test/Sema/objc-comptypes-1.m
+++ b/test/Sema/objc-comptypes-1.m
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify -pedantic %s
 
 #include <objc/objc.h>
 
@@ -33,25 +33,25 @@
   /* Assigning to a 'MyClass *' variable should always generate a
      warning, unless done from an 'id'.  */
   obj_c = obj;    /* Ok */
-  obj_c = obj_cp; // // expected-warning {{incompatible pointer types assigning 'MyOtherClass *' to 'MyClass *'}}
-  obj_c = obj_C;  // expected-warning {{incompatible pointer types assigning 'Class' to 'MyClass *'}}
+  obj_c = obj_cp; // // expected-warning {{incompatible pointer types assigning 'MyOtherClass *', expected 'MyClass *'}}
+  obj_c = obj_C;  // expected-warning {{incompatible pointer types assigning 'Class', expected 'MyClass *'}}
 
   /* Assigning to an 'id<MyProtocol>' variable should generate a
      warning if done from a 'MyClass *' (which doesn't implement
      MyProtocol), but not from an 'id' or from a 'MyOtherClass *'
      (which implements MyProtocol).  */
   obj_p = obj;    /* Ok */
-  obj_p = obj_c;  // expected-error {{incompatible types assigning 'MyClass *' to 'id<MyProtocol>'}}
+  obj_p = obj_c;  // expected-error {{incompatible type assigning 'MyClass *', expected 'id<MyProtocol>'}}
   obj_p = obj_cp; /* Ok  */
-  obj_p = obj_C;  // expected-error {{incompatible types assigning 'Class' to 'id<MyProtocol>'}}
+  obj_p = obj_C;  // expected-error {{incompatible type assigning 'Class', expected 'id<MyProtocol>'}}
 
   /* Assigning to a 'MyOtherClass *' variable should always generate
      a warning, unless done from an 'id' or an 'id<MyProtocol>' (since
      MyOtherClass implements MyProtocol).  */
   obj_cp = obj;    /* Ok */
-  obj_cp = obj_c;  // expected-warning {{incompatible pointer types assigning 'MyClass *' to 'MyOtherClass *'}}
+  obj_cp = obj_c;  // expected-warning {{incompatible pointer types assigning 'MyClass *', expected 'MyOtherClass *'}}
   obj_cp = obj_p;  /* Ok */
-  obj_cp = obj_C;  // expected-warning {{incompatible pointer types assigning 'Class' to 'MyOtherClass *'}}
+  obj_cp = obj_C;  // expected-warning {{incompatible pointer types assigning 'Class', expected 'MyOtherClass *'}}
 
   /* Any comparison involving an 'id' must be without warnings.  */
   if (obj == obj_p) foo() ;  /* Ok  */ /*Bogus warning here in 2.95.4*/
diff --git a/test/Sema/objc-comptypes-3.m b/test/Sema/objc-comptypes-3.m
index c7c4cab..4aab2d2 100644
--- a/test/Sema/objc-comptypes-3.m
+++ b/test/Sema/objc-comptypes-3.m
@@ -24,21 +24,21 @@
   id<MyProtocolAB> obj_ab = nil;
   id<MyProtocolAC> obj_ac = nil;
 
-  obj_a = obj_b;  // expected-error {{incompatible types assigning 'id<MyProtocolB>' to 'id<MyProtocolA>'}}
+  obj_a = obj_b;  // expected-error {{incompatible type assigning 'id<MyProtocolB>', expected 'id<MyProtocolA>'}}
   obj_a = obj_ab; /* Ok */
   obj_a = obj_ac; /* Ok */
   
-  obj_b = obj_a;  // expected-error {{incompatible types assigning 'id<MyProtocolA>' to 'id<MyProtocolB>'}}
+  obj_b = obj_a;  // expected-error {{incompatible type assigning 'id<MyProtocolA>', expected 'id<MyProtocolB>'}}
   obj_b = obj_ab; /* Ok */
-  obj_b = obj_ac; // expected-error {{incompatible types assigning 'id<MyProtocolAC>' to 'id<MyProtocolB>'}}
+  obj_b = obj_ac; // expected-error {{incompatible type assigning 'id<MyProtocolAC>', expected 'id<MyProtocolB>'}}
   
-  obj_ab = obj_a;  // expected-error {{incompatible types assigning 'id<MyProtocolA>' to 'id<MyProtocolAB>'}}
-  obj_ab = obj_b;  // expected-error {{incompatible types assigning 'id<MyProtocolB>' to 'id<MyProtocolAB>'}}
-  obj_ab = obj_ac; // expected-error {{incompatible types assigning 'id<MyProtocolAC>' to 'id<MyProtocolAB>'}}
+  obj_ab = obj_a;  // expected-error {{incompatible type assigning 'id<MyProtocolA>', expected 'id<MyProtocolAB>'}}
+  obj_ab = obj_b;  // expected-error {{incompatible type assigning 'id<MyProtocolB>', expected 'id<MyProtocolAB>'}}
+  obj_ab = obj_ac; // expected-error {{incompatible type assigning 'id<MyProtocolAC>', expected 'id<MyProtocolAB>'}}
   
-  obj_ac = obj_a;  // expected-error {{incompatible types assigning 'id<MyProtocolA>' to 'id<MyProtocolAC>'}}
-  obj_ac = obj_b;  // expected-error {{incompatible types assigning 'id<MyProtocolB>' to 'id<MyProtocolAC>'}}
-  obj_ac = obj_ab; // expected-error {{incompatible types assigning 'id<MyProtocolAB>' to 'id<MyProtocolAC>'}}
+  obj_ac = obj_a;  // expected-error {{incompatible type assigning 'id<MyProtocolA>', expected 'id<MyProtocolAC>'}}
+  obj_ac = obj_b;  // expected-error {{incompatible type assigning 'id<MyProtocolB>', expected 'id<MyProtocolAC>'}}
+  obj_ac = obj_ab; // expected-error {{incompatible type assigning 'id<MyProtocolAB>', expected 'id<MyProtocolAC>'}}
 
   if (obj_a == obj_b) foo (); // expected-error {{invalid operands to binary expression ('id<MyProtocolA>' and 'id<MyProtocolB>')}}
   if (obj_b == obj_a) foo (); // expected-error {{invalid operands to binary expression ('id<MyProtocolB>' and 'id<MyProtocolA>')}}
diff --git a/test/Sema/objc-comptypes-5.m b/test/Sema/objc-comptypes-5.m
index 646c6e5..508c25f 100644
--- a/test/Sema/objc-comptypes-5.m
+++ b/test/Sema/objc-comptypes-5.m
@@ -23,8 +23,8 @@
   MyClass *obj_c_cat_p = nil;
   MyOtherClass *obj_c_super_p = nil;
 
-  obj_c_cat_p = obj_id_p;   // expected-error {{incompatible types assigning 'id<MyProtocol>' to 'MyClass *'}}
-  obj_c_super_p = obj_id_p;  // expected-error {{incompatible types assigning 'id<MyProtocol>' to 'MyOtherClass *'}}
+  obj_c_cat_p = obj_id_p;   // expected-error {{incompatible type assigning 'id<MyProtocol>', expected 'MyClass *'}}
+  obj_c_super_p = obj_id_p;  // expected-error {{incompatible type assigning 'id<MyProtocol>', expected 'MyOtherClass *'}}
   obj_id_p = obj_c_cat_p;  /* Ok */
   obj_id_p = obj_c_super_p; /* Ok */
 
diff --git a/test/Sema/objc-comptypes-6.m b/test/Sema/objc-comptypes-6.m
index ca2b131..dd9b396 100644
--- a/test/Sema/objc-comptypes-6.m
+++ b/test/Sema/objc-comptypes-6.m
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify -pedantic %s
 
 #include <objc/Object.h>
 
@@ -9,7 +9,7 @@
 
 static Derived *test(void)
 {
-   Derived *m = foo();   // expected-warning {{incompatible pointer types assigning 'Object *' to 'Derived *'}}
+   Derived *m = foo();   // expected-warning {{incompatible pointer types initializing 'Object *', expected 'Derived *'}}
 
    return m;
 }
diff --git a/test/Sema/objc-comptypes-7.m b/test/Sema/objc-comptypes-7.m
index e4c949a..9d8f211 100644
--- a/test/Sema/objc-comptypes-7.m
+++ b/test/Sema/objc-comptypes-7.m
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %s
+// RUN: clang -fsyntax-only -verify -pedantic %s
 
 #include <objc/objc.h>
 
@@ -23,27 +23,27 @@
 
   /* These should all generate warnings.  */
   
-  obj = i; // expected-warning {{incompatible types assigning 'int' to 'id'}}
-  obj = j; // expected-warning {{incompatible pointer types assigning 'int *' to 'id'}}
+  obj = i; // expected-warning {{incompatible pointer/int conversion assigning 'int', expected 'id'}}
+  obj = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'id'}}
 
-  obj_p = i; // expected-error {{incompatible types assigning 'int' to 'id<MyProtocol>' }}
-  obj_p = j; // expected-error {{incompatible types assigning 'int *' to 'id<MyProtocol>'}}
+  obj_p = i; // expected-error {{incompatible type assigning 'int', expected 'id<MyProtocol>' }}
+  obj_p = j; // expected-error {{incompatible type assigning 'int *', expected 'id<MyProtocol>'}}
   
-  obj_c = i; // expected-warning {{incompatible types assigning 'int' to 'MyClass *'}}
-  obj_c = j; // expected-warning {{incompatible pointer types assigning 'int *' to 'MyClass *'}}
+  obj_c = i; // expected-warning {{incompatible pointer/int conversion assigning 'int', expected 'MyClass *'}}
+  obj_c = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'MyClass *'}}
 
-  obj_C = i; // expected-warning {{incompatible types assigning 'int' to 'Class'}}
-  obj_C = j; // expected-warning {{incompatible pointer types assigning 'int *' to 'Class'}}
+  obj_C = i; // expected-warning {{incompatible pointer/int conversion assigning 'int', expected 'Class'}}
+  obj_C = j; // expected-warning {{incompatible pointer types assigning 'int *', expected 'Class'}}
   
-  i = obj;   // expected-warning {{incompatible types assigning 'id' to 'int'}}
-  i = obj_p; // expected-error {{incompatible types assigning 'id<MyProtocol>' to 'int'}}
-  i = obj_c; // expected-warning {{incompatible types assigning 'MyClass *' to 'int'}}
-  i = obj_C; // expected-warning {{incompatible types assigning 'Class' to 'int'}}
+  i = obj;   // expected-warning {{incompatible pointer/int conversion assigning 'id', expected 'int'}}
+  i = obj_p; // expected-error {{incompatible type assigning 'id<MyProtocol>', expected 'int'}}
+  i = obj_c; // expected-warning {{incompatible pointer/int conversion assigning 'MyClass *', expected 'int'}}
+  i = obj_C; // expected-warning {{incompatible pointer/int conversion assigning 'Class', expected 'int'}}
   
-  j = obj;   // expected-warning {{incompatible pointer types assigning 'id' to 'int *'}}
-  j = obj_p; // expected-error {{incompatible types assigning 'id<MyProtocol>' to 'int *'}}
-  j = obj_c; // expected-warning {{incompatible pointer types assigning 'MyClass *' to 'int *'}}
-  j = obj_C; // expected-warning {{incompatible pointer types assigning 'Class' to 'int *'}}
+  j = obj;   // expected-warning {{incompatible pointer types assigning 'id', expected 'int *'}}
+  j = obj_p; // expected-error {{incompatible type assigning 'id<MyProtocol>', expected 'int *'}}
+  j = obj_c; // expected-warning {{incompatible pointer types assigning 'MyClass *', expected 'int *'}}
+  j = obj_C; // expected-warning {{incompatible pointer types assigning 'Class', expected 'int *'}}
   
   if (obj == i) foo() ; // expected-warning {{comparison between pointer and integer ('id' and 'int')}}
   if (i == obj) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id')}}
diff --git a/test/Sema/protocol-id-test-3.m b/test/Sema/protocol-id-test-3.m
index 058be26..8c2beee 100644
--- a/test/Sema/protocol-id-test-3.m
+++ b/test/Sema/protocol-id-test-3.m
@@ -29,7 +29,7 @@
 
 id<MyProto1, MyProto2> Gunc2(id <MyProto1>p2)
 {
-	Func(p2);	// expected-error {{incompatible types passing 'id<MyProto1>' to function expecting 'INTF<MyProto1,MyProto2> *'}}
+	Func(p2);	// expected-error {{incompatible type passing 'id<MyProto1>', expected 'INTF<MyProto1,MyProto2> *'}}
 	return p2;	// expected-error {{incompatible type returning 'id<MyProto1>', expected 'id<MyProto1,MyProto2>'}}
 }
 
@@ -61,7 +61,7 @@
 
 INTF<MyProto1, MyProto2> * Hunc2(id <MyProto1>p2)
 {
-	Func(p2);	// expected-error {{incompatible types passing 'id<MyProto1>' to function expecting 'INTF<MyProto1,MyProto2> *'}}
+	Func(p2);	// expected-error {{incompatible type passing 'id<MyProto1>', expected 'INTF<MyProto1,MyProto2> *'}}
 	return p2;	// expected-error {{incompatible type returning 'id<MyProto1>', expected 'INTF<MyProto1,MyProto2> *'}}
 }
 
diff --git a/test/Sema/typedef-retain.c b/test/Sema/typedef-retain.c
index 9647c74..72d3b41 100644
--- a/test/Sema/typedef-retain.c
+++ b/test/Sema/typedef-retain.c
@@ -5,10 +5,10 @@
 typedef int4* int4p;
 
 void test1(float4 a, int4 *result, int i) {
-    result[i] = a; // expected-error {{assigning 'float4' to 'int4'}}
+    result[i] = a; // expected-error {{assigning 'float4', expected 'int4'}}
 }
 
 void test2(float4 a, int4p result, int i) {
-    result[i] = a; // expected-error {{assigning 'float4' to 'int4'}}
+    result[i] = a; // expected-error {{assigning 'float4', expected 'int4'}}
 }
 
diff --git a/test/Sema/vector-assign.c b/test/Sema/vector-assign.c
index ff64422..6f68181 100644
--- a/test/Sema/vector-assign.c
+++ b/test/Sema/vector-assign.c
@@ -13,27 +13,27 @@
   v4ss v5;
   
   v1 = v2; 
-  v1 = v3; // expected-error {{incompatible types assigning 'v1s' to 'v2s'}}
-  v1 = v4; // expected-error {{incompatible types assigning 'v2f' to 'v2s'}}
+  v1 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v2s'}}
+  v1 = v4; // expected-error {{incompatible type assigning 'v2f', expected 'v2s'}}
   v1 = v5;
   
   v2 = v1;
-  v2 = v3; // expected-error {{incompatible types assigning 'v1s' to 'v2u'}}
-  v2 = v4; // expected-error {{incompatible types assigning 'v2f' to 'v2u'}}
+  v2 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v2u'}}
+  v2 = v4; // expected-error {{incompatible type assigning 'v2f', expected 'v2u'}}
   v2 = v5;
   
-  v3 = v1; // expected-error {{incompatible types assigning 'v2s' to 'v1s'}}
-  v3 = v2; // expected-error {{incompatible types assigning 'v2u' to 'v1s'}}
-  v3 = v4; // expected-error {{incompatible types assigning 'v2f' to 'v1s'}}
-  v3 = v5; // expected-error {{incompatible types assigning 'v4ss' to 'v1s'}}
+  v3 = v1; // expected-error {{incompatible type assigning 'v2s', expected 'v1s'}}
+  v3 = v2; // expected-error {{incompatible type assigning 'v2u', expected 'v1s'}}
+  v3 = v4; // expected-error {{incompatible type assigning 'v2f', expected 'v1s'}}
+  v3 = v5; // expected-error {{incompatible type assigning 'v4ss', expected 'v1s'}}
   
-  v4 = v1; // expected-error {{incompatible types assigning 'v2s' to 'v2f'}}
-  v4 = v2; // expected-error {{incompatible types assigning 'v2u' to 'v2f'}}
-  v4 = v3; // expected-error {{incompatible types assigning 'v1s' to 'v2f'}}
-  v4 = v5; // expected-error {{incompatible types assigning 'v4ss' to 'v2f'}}
+  v4 = v1; // expected-error {{incompatible type assigning 'v2s', expected 'v2f'}}
+  v4 = v2; // expected-error {{incompatible type assigning 'v2u', expected 'v2f'}}
+  v4 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v2f'}}
+  v4 = v5; // expected-error {{incompatible type assigning 'v4ss', expected 'v2f'}}
   
   v5 = v1;
   v5 = v2;
-  v5 = v3; // expected-error {{incompatible types assigning 'v1s' to 'v4ss'}}
-  v5 = v4; // expected-error {{incompatible types assigning 'v2f' to 'v4ss'}}
+  v5 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v4ss'}}
+  v5 = v4; // expected-error {{incompatible type assigning 'v2f', expected 'v4ss'}}
 }