aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-06-11 04:42:12 +0000
committerDouglas Gregor <dgregor@apple.com>2011-06-11 04:42:12 +0000
commit8cf0d22420eab58b8b434fa5d3a6e83c63ddefdd (patch)
tree5dddb0070a2d58941f65fed944581d678d033494
parent926df6cfabf3eaa4afc990c097fa4619b76a9b57 (diff)
Fix order of operands for the warning about incompatible Objective-C
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
-rw-r--r--lib/Sema/SemaExprCXX.cpp2
-rw-r--r--test/SemaObjCXX/overload.mm4
-rw-r--r--test/SemaObjCXX/related-result-type-inference.mm2
3 files changed, 4 insertions, 4 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 27659f6507..50462abd3a 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -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
diff --git a/test/SemaObjCXX/overload.mm b/test/SemaObjCXX/overload.mm
index 960a7b228f..ea5f0e5932 100644
--- a/test/SemaObjCXX/overload.mm
+++ b/test/SemaObjCXX/overload.mm
@@ -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
diff --git a/test/SemaObjCXX/related-result-type-inference.mm b/test/SemaObjCXX/related-result-type-inference.mm
index 58fb961e23..accec793ad 100644
--- a/test/SemaObjCXX/related-result-type-inference.mm
+++ b/test/SemaObjCXX/related-result-type-inference.mm
@@ -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 *'}}
}