From f2b4f7b6772ccba2ea8aae411ea09d8d32d90015 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 12 Jan 2012 22:12:08 +0000 Subject: [PATCH] objc: do not warn when converting to a const id qualfied by its list of protools. // rdar://10669694 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148051 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 4 +++- .../ignore-qualifier-on-qualified-id.m | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/SemaObjC/ignore-qualifier-on-qualified-id.m diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index ceb836b3e8..8625d9b260 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -5304,7 +5304,9 @@ checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType lhptee = LHSType->getAs()->getPointeeType(); QualType rhptee = RHSType->getAs()->getPointeeType(); - if (!lhptee.isAtLeastAsQualifiedAs(rhptee)) + if (!lhptee.isAtLeastAsQualifiedAs(rhptee) && + // make an exception for id

+ !LHSType->isObjCQualifiedIdType()) return Sema::CompatiblePointerDiscardsQualifiers; if (S.Context.typesAreCompatible(LHSType, RHSType)) diff --git a/test/SemaObjC/ignore-qualifier-on-qualified-id.m b/test/SemaObjC/ignore-qualifier-on-qualified-id.m new file mode 100644 index 0000000000..36a2c1ad87 --- /dev/null +++ b/test/SemaObjC/ignore-qualifier-on-qualified-id.m @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s +// rdar://10667659 + +@protocol NSCopying @end + +@interface NSString +@end + +void takeId(id test) {} + +void takeCopyableId(id test) {} + +id Test () { + NSString const *constantString = @"Test"; + takeId(constantString); + takeCopyableId(constantString); + id ID = constantString; + id IDQNSCopying = constantString; + return constantString; +} -- 2.40.0