]> granicus.if.org Git - clang/commitdiff
Fix an objc++ diagnostic initializing objc pointers.
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 21 Mar 2011 19:08:42 +0000 (19:08 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 21 Mar 2011 19:08:42 +0000 (19:08 +0000)
// rdar:// 9139947

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128013 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaObjCXX/objc-pointer-conv.mm
test/SemaObjCXX/overload.mm

index 8ceeff953647a49f42060817c07b7f1a1f2312ea..8fa2a5d2e86f476d4539a4f654d5eeeadc443758 100644 (file)
@@ -2153,10 +2153,16 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
   case ICK_Pointer_Conversion: {
     if (SCS.IncompatibleObjC && Action != AA_Casting) {
       // Diagnose incompatible Objective-C conversions
-      Diag(From->getSourceRange().getBegin(),
-           diag::ext_typecheck_convert_incompatible_pointer)
-        << From->getType() << ToType << Action
-        << From->getSourceRange();
+      if (Action == AA_Initializing)
+        Diag(From->getSourceRange().getBegin(),
+             diag::ext_typecheck_convert_incompatible_pointer)
+          << ToType << From->getType() << Action
+          << From->getSourceRange();
+      else
+        Diag(From->getSourceRange().getBegin(),
+             diag::ext_typecheck_convert_incompatible_pointer)
+          << From->getType() << ToType << Action
+          << From->getSourceRange();
     }
 
     CastKind Kind = CK_Invalid;
index 209dcfdfd70590ab1f7388e19e697d41682c8fe1..6f59de179472b2b5cf8c0acb6920747a113023f4 100644 (file)
@@ -43,6 +43,6 @@ void accept_derived(DerivedFromI*);
 
 void test_base_to_derived(I* i) {
   accept_derived(i); // expected-warning{{incompatible pointer types passing 'I *' to parameter of type 'DerivedFromI *'}}
-  DerivedFromI *di = i; // expected-warning{{incompatible pointer types initializing 'I *' with an expression of type 'DerivedFromI *'}}
+  DerivedFromI *di = i; // expected-warning{{incompatible pointer types initializing 'DerivedFromI *' with an expression of type 'I *'}}
   DerivedFromI *di2 = (DerivedFromI *)i;
 }
index 7e79a4249cb0d227c2f3f43c82838223b64e12eb..a40248e6cd2a81b9c5ae0ad494b0d14f7430e6d0 100644 (file)
@@ -51,12 +51,12 @@ void test0(A* a, B* b, id val) {
 }
 
 void test1(A* a) {
-  B* b = a; // expected-warning{{incompatible pointer types initializing 'A *' with an expression of type 'B *'}}
+  B* b = a; // expected-warning{{incompatible pointer types initializing 'B *' with an expression of type 'A *'}}
   B *c; c = a; // expected-warning{{incompatible pointer types assigning to 'A *' from 'B *'}}
 }
 
 void test2(A** ap) {
-  B** bp = ap; // expected-warning{{incompatible pointer types initializing 'A **' with an expression of type 'B **'}}
+  B** bp = ap; // expected-warning{{incompatible pointer types initializing 'B **' with an expression of type 'A **'}}
   bp = ap; // expected-warning{{incompatible pointer types assigning to 'A **' from 'B **'}}
 }