r180765 - Objective-C (mostly arc): Under ARC, we often have unneeded qualifiers

Fariborz Jahanian fjahanian at apple.com
Mon Apr 29 17:30:48 PDT 2013


Author: fjahanian
Date: Mon Apr 29 19:30:48 2013
New Revision: 180765

URL: http://llvm.org/viewvc/llvm-project?rev=180765&view=rev
Log:
Objective-C (mostly arc): Under ARC, we often have unneeded qualifiers 
in the diagnostics. Remove them when reporting incompatible
Objective-C pointer types. // rdar://13752880.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=180765&r1=180764&r2=180765&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Apr 29 19:30:48 2013
@@ -10170,6 +10170,10 @@ bool Sema::DiagnoseAssignmentResult(Assi
     if (Hint.isNull() && !CheckInferredResultType) {
       ConvHints.tryToFixConversion(SrcExpr, SrcType, DstType, *this);
     }
+    else if (CheckInferredResultType) {
+      SrcType = SrcType.getUnqualifiedType();
+      DstType = DstType.getUnqualifiedType();
+    }
     MayHaveConvFixit = true;
     break;
   case IncompatiblePointerSign:

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=180765&r1=180764&r2=180765&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test/SemaObjC/arc.m Mon Apr 29 19:30:48 2013
@@ -756,3 +756,14 @@ void rdar12569201(id key, id value) {
 @interface C
 - (void)method:(id[])objects; // expected-error{{must explicitly describe intended ownership of an object array parameter}}
 @end
+
+// rdar://13752880
+ at interface NSMutableArray : NSArray @end
+
+typedef __strong NSMutableArray * PSNS;
+
+void test(NSArray *x) {
+  NSMutableArray *y = x; // expected-warning {{incompatible pointer types initializing 'NSMutableArray *' with an expression of type 'NSArray *'}}
+  __strong NSMutableArray *y1 = x; // expected-warning {{incompatible pointer types initializing 'NSMutableArray *' with an expression of type 'NSArray *'}}
+  PSNS y2 = x; // expected-warning {{incompatible pointer types initializing 'NSMutableArray *' with an expression of type 'NSArray *'}}
+}





More information about the cfe-commits mailing list