[cfe-commits] r148051 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/ignore-qualifier-on-qualified-id.m

Fariborz Jahanian fjahanian at apple.com
Thu Jan 12 14:12:08 PST 2012


Author: fjahanian
Date: Thu Jan 12 16:12:08 2012
New Revision: 148051

URL: http://llvm.org/viewvc/llvm-project?rev=148051&view=rev
Log:
objc: do not warn when converting to a const id qualfied by its
list of protools. // rdar://10669694

Added:
    cfe/trunk/test/SemaObjC/ignore-qualifier-on-qualified-id.m
Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=148051&r1=148050&r2=148051&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jan 12 16:12:08 2012
@@ -5304,7 +5304,9 @@
   QualType lhptee = LHSType->getAs<ObjCObjectPointerType>()->getPointeeType();
   QualType rhptee = RHSType->getAs<ObjCObjectPointerType>()->getPointeeType();
 
-  if (!lhptee.isAtLeastAsQualifiedAs(rhptee))
+  if (!lhptee.isAtLeastAsQualifiedAs(rhptee) &&
+      // make an exception for id<P>
+      !LHSType->isObjCQualifiedIdType())
     return Sema::CompatiblePointerDiscardsQualifiers;
 
   if (S.Context.typesAreCompatible(LHSType, RHSType))

Added: cfe/trunk/test/SemaObjC/ignore-qualifier-on-qualified-id.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/ignore-qualifier-on-qualified-id.m?rev=148051&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/ignore-qualifier-on-qualified-id.m (added)
+++ cfe/trunk/test/SemaObjC/ignore-qualifier-on-qualified-id.m Thu Jan 12 16:12:08 2012
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// rdar://10667659
+
+ at protocol NSCopying @end
+
+ at interface NSString <NSCopying>
+ at end
+
+void takeId(id test) {}
+
+void takeCopyableId(id<NSCopying> test) {}
+
+id<NSCopying> Test () {
+  NSString const *constantString = @"Test";
+  takeId(constantString);
+  takeCopyableId(constantString);
+  id ID = constantString;
+  id<NSCopying> IDQNSCopying = constantString;
+  return constantString;
+}





More information about the cfe-commits mailing list