diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-07-13 17:55:01 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-07-13 17:55:01 +0000 |
commit | 8beb6a2426b5a6b79ecf019316d9fbd30755e087 (patch) | |
tree | 80e9f6bf14dacbd1ce6d5dcd8014dc6a8c2d252f | |
parent | dc00d8158db573f4a1f91cfaa2a89171c2e5f637 (diff) |
objc++: Some level of covariance is allowed in ObjC properties.
Make it also available in ObjC++ propeties. Use common code for
objc and objc++ so they don't diverge. // rdar://9740328
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135050 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 15 | ||||
-rw-r--r-- | test/SemaObjC/property-inherited.m | 4 | ||||
-rw-r--r-- | test/SemaObjCXX/property-type-mismatch.mm | 1 |
3 files changed, 12 insertions, 8 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 27f25c27ad..842d614294 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -910,12 +910,15 @@ Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property, Context.getCanonicalType(Property->getType()); if (!Context.propertyTypesAreCompatible(LHSType, RHSType)) { - // FIXME: Incorporate this test with typesAreCompatible. - if (LHSType->isObjCQualifiedIdType() && RHSType->isObjCQualifiedIdType()) - if (Context.ObjCQualifiedIdTypesAreCompatible(LHSType, RHSType, false)) - return; - Diag(Property->getLocation(), diag::warn_property_types_are_incompatible) - << Property->getType() << SuperProperty->getType() << inheritedName; + // Do cases not handled in above. + // FIXME. For future support of covariant property types, revisit this. + bool IncompatibleObjC = false; + QualType ConvertedType; + if (!isObjCPointerConversion(RHSType, LHSType, + ConvertedType, IncompatibleObjC) || + IncompatibleObjC) + Diag(Property->getLocation(), diag::warn_property_types_are_incompatible) + << Property->getType() << SuperProperty->getType() << inheritedName; } } diff --git a/test/SemaObjC/property-inherited.m b/test/SemaObjC/property-inherited.m index 5c5631e6fb..11ef2befa9 100644 --- a/test/SemaObjC/property-inherited.m +++ b/test/SemaObjC/property-inherited.m @@ -1,6 +1,8 @@ // RUN: %clang_cc1 %s -fsyntax-only -verify +// RUN: %clang_cc1 -x objective-c++ %s -fsyntax-only -verify -// <rdar://problem/6497242> Inherited overridden protocol declared objects don't work +// rdar://6497242 Inherited overridden protocol declared objects don't work +// rdar://9740328 Case for c++ @protocol NSObject @end @interface NSObject @end diff --git a/test/SemaObjCXX/property-type-mismatch.mm b/test/SemaObjCXX/property-type-mismatch.mm index a818b2d44c..059793cf5c 100644 --- a/test/SemaObjCXX/property-type-mismatch.mm +++ b/test/SemaObjCXX/property-type-mismatch.mm @@ -1,6 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s // rdar://9740328 -// XFAIL: * @protocol P1; |