return true; // FIXME: IMPLEMENT.
}
+bool ASTContext::QualifiedInterfaceTypesAreCompatible(QualType lhs,
+ QualType rhs) {
+ ObjcQualifiedInterfaceType *lhsQI =
+ dyn_cast<ObjcQualifiedInterfaceType>(lhs.getCanonicalType().getTypePtr());
+ assert(lhsQI && "QualifiedInterfaceTypesAreCompatible - bad lhs type");
+ ObjcQualifiedInterfaceType *rhsQI =
+ dyn_cast<ObjcQualifiedInterfaceType>(rhs.getCanonicalType().getTypePtr());
+ assert(rhsQI && "QualifiedInterfaceTypesAreCompatible - bad rhs type");
+ if (!interfaceTypesAreCompatible(QualType(lhsQI->getInterfaceType(), 0),
+ QualType(rhsQI->getInterfaceType(), 0)))
+ return false;
+ /* All protocols in lhs must have a presense in rhs. */
+ for (unsigned i =0; i < lhsQI->getNumProtocols(); i++) {
+ bool match = false;
+ ObjcProtocolDecl *lhsProto = lhsQI->getProtocols(i);
+ for (unsigned j = 0; j < rhsQI->getNumProtocols(); j++) {
+ ObjcProtocolDecl *rhsProto = rhsQI->getProtocols(j);
+ if (lhsProto == rhsProto) {
+ match = true;
+ break;
+ }
+ }
+ if (!match)
+ return false;
+ }
+ return true;
+}
+
bool ASTContext::vectorTypesAreCompatible(QualType lhs, QualType rhs) {
const VectorType *lVector = lhs->getAsVectorType();
const VectorType *rVector = rhs->getAsVectorType();
case Type::Vector:
case Type::OCUVector:
return vectorTypesAreCompatible(lcanon, rcanon);
+ case Type::ObjcQualifiedInterface:
+ return QualifiedInterfaceTypesAreCompatible(lcanon, rcanon);
default:
assert(0 && "unexpected type");
}
/// Objective-C specific type checking.
bool interfaceTypesAreCompatible(QualType, QualType);
+ bool QualifiedInterfaceTypesAreCompatible(QualType, QualType);
bool objcTypesAreCompatible(QualType, QualType);
bool isObjcIdType(QualType T) const {
if (!IdStructType) // ObjC isn't enabled
--- /dev/null
+// RUN: clang -fsyntax-only -verify %s
+
+@protocol MyProto1
+@end
+
+@protocol MyProto2
+@end
+
+@interface INTF @end
+
+INTF <MyProto1> * Func(INTF <MyProto1, MyProto2> *p2)
+{
+ return p2;
+}
+
+
+INTF <MyProto1> * Func1(INTF <MyProto1, MyProto2> *p2)
+{
+ return p2;
+}
+
+INTF <MyProto1, MyProto2> * Func2(INTF <MyProto1> *p2)
+{
+ Func(p2); // expected-warning {{incompatible pointer types passing}}
+ return p2; // expected-warning {{incompatible pointer types passing}}
+}
+
+
+
+INTF <MyProto1> * Func3(INTF <MyProto2> *p2)
+{
+ return p2; // expected-warning {{incompatible pointer types passing}}
+}
+
+
+INTF <MyProto1, MyProto2> * Func4(INTF <MyProto2, MyProto1> *p2)
+{
+ return p2;
+}
+