objective-c++ must take into account qualifiers when

considering valid objc pointer converions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98557 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2010-03-15 18:36:00 +00:00
Родитель 8efb5812b8
Коммит ee9ca6966d
2 изменённых файлов: 18 добавлений и 0 удалений

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

@ -1135,6 +1135,12 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
// Objective C++: We're able to convert from a pointer to an
// interface to a pointer to a different interface.
if (Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
const ObjCInterfaceType* LHS = ToObjCPtr->getInterfaceType();
const ObjCInterfaceType* RHS = FromObjCPtr->getInterfaceType();
if (getLangOptions().CPlusPlus && LHS && RHS &&
!ToObjCPtr->getPointeeType().isAtLeastAsQualifiedAs(
FromObjCPtr->getPointeeType()))
return false;
ConvertedType = ToType;
return true;
}

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

@ -24,3 +24,15 @@ void RandomFunc(CFMDRef theDict, const void *key, const void *value);
RandomFunc((CFMDRef)dict, key, objects[3]);
}
@end
@interface I
- (void) Meth : (I*) Arg;
@end
void Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'I const *' to 'I *' for 1st argument}}
void foo(const I *p, I* sel) {
[sel Meth : p]; // expected-error {{incompatible type sending 'I const *', expected 'I *'}}
Func(p); // expected-error {{no matching function for call to 'Func'}}
}