[cfe-commits] r92856 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/continuation-class-property.m
Fariborz Jahanian
fjahanian at apple.com
Wed Jan 6 13:38:31 PST 2010
Author: fjahanian
Date: Wed Jan 6 15:38:30 2010
New Revision: 92856
URL: http://llvm.org/viewvc/llvm-project?rev=92856&view=rev
Log:
Fix a bug when property is redeclared in multiple
continuation classes and its original declaration
is imported from a protocol. This fixes radar 7509234.
Added:
cfe/trunk/test/SemaObjC/continuation-class-property.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=92856&r1=92855&r2=92856&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Jan 6 15:38:30 2010
@@ -2019,6 +2019,32 @@
Diag(AtLoc, diag::warn_property_attr_mismatch);
Diag(PIDecl->getLocation(), diag::note_property_declare);
}
+ DeclContext *DC = dyn_cast<DeclContext>(CCPrimary);
+ assert(DC && "ClassDecl is not a DeclContext");
+ DeclContext::lookup_result Found =
+ DC->lookup(PIDecl->getDeclName());
+ bool PropertyInPrimaryClass = false;
+ for (; Found.first != Found.second; ++Found.first)
+ if (isa<ObjCPropertyDecl>(*Found.first)) {
+ PropertyInPrimaryClass = true;
+ break;
+ }
+ if (!PropertyInPrimaryClass) {
+ // Protocol is not in the primary class. Must build one for it.
+ ObjCDeclSpec ProtocolPropertyODS;
+ // FIXME. Assuming that ObjCDeclSpec::ObjCPropertyAttributeKind and
+ // ObjCPropertyDecl::PropertyAttributeKind have identical values.
+ // Should consolidate both into one enum type.
+ ProtocolPropertyODS.setPropertyAttributes(
+ (ObjCDeclSpec::ObjCPropertyAttributeKind)PIkind);
+ DeclPtrTy ProtocolPtrTy =
+ ActOnProperty(S, AtLoc, FD, ProtocolPropertyODS,
+ PIDecl->getGetterName(),
+ PIDecl->getSetterName(),
+ DeclPtrTy::make(CCPrimary), isOverridingProperty,
+ MethodImplKind);
+ PIDecl = ProtocolPtrTy.getAs<ObjCPropertyDecl>();
+ }
PIDecl->makeitReadWriteAttribute();
if (Attributes & ObjCDeclSpec::DQ_PR_retain)
PIDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_retain);
Added: cfe/trunk/test/SemaObjC/continuation-class-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/continuation-class-property.m?rev=92856&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/continuation-class-property.m (added)
+++ cfe/trunk/test/SemaObjC/continuation-class-property.m Wed Jan 6 15:38:30 2010
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// radar 7509234
+
+ at protocol Foo
+ at property (readonly, copy) id foos;
+ at end
+
+ at interface Bar <Foo> {
+}
+
+ at end
+
+ at interface Baz <Foo> {
+}
+ at end
+
+ at interface Bar ()
+ at property (readwrite, copy) id foos;
+ at end
+
+ at interface Baz ()
+ at property (readwrite, copy) id foos;
+ at end
+
More information about the cfe-commits
mailing list