[cfe-commits] r121047 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaObjCXX/overload.mm
Douglas Gregor
dgregor at apple.com
Mon Dec 6 14:09:19 PST 2010
Author: dgregor
Date: Mon Dec 6 16:09:19 2010
New Revision: 121047
URL: http://llvm.org/viewvc/llvm-project?rev=121047&view=rev
Log:
Objective-C pointer conversions to 'id' or qualified 'id' subsume
cv-qualification conversions. More specifically, there's an implicit
cv-qualification conversion (even one that drops qualifiers) when
converting to 'id' or qualified 'id'. Fixes <rdar://problem/8734046>.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaObjCXX/overload.mm
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=121047&r1=121046&r2=121047&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Dec 6 16:09:19 2010
@@ -1365,6 +1365,11 @@
assert((FromPtr->getTypeClass() == Type::Pointer ||
FromPtr->getTypeClass() == Type::ObjCObjectPointer) &&
"Invalid similarly-qualified pointer type");
+
+ /// \brief Conversions to 'id' subsume cv-qualifier conversions.
+ if (ToType->isObjCIdType() || ToType->isObjCQualifiedIdType())
+ return ToType.getUnqualifiedType();
+
QualType CanonFromPointee
= Context.getCanonicalType(FromPtr->getPointeeType());
QualType CanonToPointee = Context.getCanonicalType(ToPointee);
Modified: cfe/trunk/test/SemaObjCXX/overload.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/overload.mm?rev=121047&r1=121046&r2=121047&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/overload.mm (original)
+++ cfe/trunk/test/SemaObjCXX/overload.mm Mon Dec 6 16:09:19 2010
@@ -142,3 +142,12 @@
}
+
+namespace rdar8734046 {
+ void f1(id);
+ void f2(id<P0>);
+ void g(const A *a) {
+ f1(a);
+ f2(a);
+ }
+}
More information about the cfe-commits
mailing list