From 2720dc656bca9f9a4b1c115e85481af5c07536e3 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 11 Jun 2011 04:42:12 +0000 Subject: [PATCH] Fix order of operands for the warning about incompatible Objective-C pointer assignment in C++. This was a longstanding problem spotted by Jordy Rose. llvm-svn: 132873 --- clang/lib/Sema/SemaExprCXX.cpp | 2 +- clang/test/SemaObjCXX/overload.mm | 4 ++-- clang/test/SemaObjCXX/related-result-type-inference.mm | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 27659f65077b..50462abd3a44 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/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/clang/test/SemaObjCXX/overload.mm b/clang/test/SemaObjCXX/overload.mm index 960a7b228ff3..ea5f0e593284 100644 --- a/clang/test/SemaObjCXX/overload.mm +++ b/clang/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/clang/test/SemaObjCXX/related-result-type-inference.mm b/clang/test/SemaObjCXX/related-result-type-inference.mm index 58fb961e23d9..accec793ad38 100644 --- a/clang/test/SemaObjCXX/related-result-type-inference.mm +++ b/clang/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 *'}} } -- GitLab