[cfe-commits] r128013 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaObjCXX/objc-pointer-conv.mm test/SemaObjCXX/overload.mm

Fariborz Jahanian fjahanian at apple.com
Mon Mar 21 12:08:42 PDT 2011


Author: fjahanian
Date: Mon Mar 21 14:08:42 2011
New Revision: 128013

URL: http://llvm.org/viewvc/llvm-project?rev=128013&view=rev
Log:
Fix an objc++ diagnostic initializing objc pointers.
// rdar:// 9139947

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm
    cfe/trunk/test/SemaObjCXX/overload.mm

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=128013&r1=128012&r2=128013&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Mar 21 14:08:42 2011
@@ -2153,10 +2153,16 @@
   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;

Modified: cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm?rev=128013&r1=128012&r2=128013&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm (original)
+++ cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm Mon Mar 21 14:08:42 2011
@@ -43,6 +43,6 @@
 
 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;
 }

Modified: cfe/trunk/test/SemaObjCXX/overload.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/overload.mm?rev=128013&r1=128012&r2=128013&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/overload.mm (original)
+++ cfe/trunk/test/SemaObjCXX/overload.mm Mon Mar 21 14:08:42 2011
@@ -51,12 +51,12 @@
 }
 
 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 **'}}
 }
 





More information about the cfe-commits mailing list