]> granicus.if.org Git - clang/commitdiff
Fix order of operands for the warning about incompatible Objective-C
authorDouglas Gregor <dgregor@apple.com>
Sat, 11 Jun 2011 04:42:12 +0000 (04:42 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 11 Jun 2011 04:42:12 +0000 (04:42 +0000)
pointer assignment in C++. This was a longstanding problem spotted by
Jordy Rose.

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

lib/Sema/SemaExprCXX.cpp
test/SemaObjCXX/overload.mm
test/SemaObjCXX/related-result-type-inference.mm

index 27659f65077b7515098362fc38d81cb1e5d85dc8..50462abd3a44d9072b67c7f82488d4c8f5bb86e0 100644 (file)
@@ -2211,7 +2211,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
   case ICK_Pointer_Conversion: {
     if (SCS.IncompatibleObjC && Action != AA_Casting) {
       // Diagnose incompatible Objective-C conversions
-      if (Action == AA_Initializing)
+      if (Action == AA_Initializing || Action == AA_Assigning)
         Diag(From->getSourceRange().getBegin(),
              diag::ext_typecheck_convert_incompatible_pointer)
           << ToType << From->getType() << Action
index 960a7b228ff336989a3ee9e5b3597951a6f4b577..ea5f0e59328423ee961839998d063656b7e251de 100644 (file)
@@ -52,12 +52,12 @@ void test0(A* a, B* b, id val) {
 
 void test1(A* a) {
   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 *'}}
+  B *c; c = a; // expected-warning{{incompatible pointer types assigning to 'B *' from 'A *'}}
 }
 
 void test2(A** ap) {
   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 **'}}
+  bp = ap; // expected-warning{{incompatible pointer types assigning to 'B **' from 'A **'}}
 }
 
 // FIXME: we should either allow overloading here or give a better diagnostic
index 58fb961e23d9b2a56cdd5f475ca61c7a79c6bc49..accec793ad3804b08c8deecec2bffb652e77f513 100644 (file)
@@ -66,5 +66,5 @@ void test_inference() {
 
   NSArray *arr = [[NSMutableArray alloc] init];
   NSMutableArray *marr = [arr retain]; // expected-warning{{incompatible pointer types initializing 'NSMutableArray *' with an expression of type 'NSArray *'}}
-  marr = [arr retain]; // expected-warning{{incompatible pointer types assigning to 'NSArray *' from 'NSMutableArray *'}}
+  marr = [arr retain]; // expected-warning{{incompatible pointer types assigning to 'NSMutableArray *' from 'NSArray *'}}
 }