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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121047 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2010-12-06 22:09:19 +00:00
Родитель 409fa9ab95
Коммит 143c7acef3
2 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -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);

Просмотреть файл

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