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>.

llvm-svn: 121047
This commit is contained in:
Douglas Gregor 2010-12-06 22:09:19 +00:00
parent 73b7b93d42
commit c6bd1d32bf
2 changed files with 14 additions and 0 deletions

View File

@ -1365,6 +1365,11 @@ BuildSimilarlyQualifiedPointerType(const Type *FromPtr,
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);

View File

@ -142,3 +142,12 @@ namespace rdar8714395 {
}
namespace rdar8734046 {
void f1(id);
void f2(id<P0>);
void g(const A *a) {
f1(a);
f2(a);
}
}