Fix a bug when property is redeclared in multiple

continuation classes and its original declaration
is imported from a protocol. This fixes radar 7509234.

llvm-svn: 92856
This commit is contained in:
Fariborz Jahanian 2010-01-06 21:38:30 +00:00
parent ccecc1bb43
commit 8e356bfe28
2 changed files with 50 additions and 0 deletions

View File

@ -2019,6 +2019,32 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
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);

View File

@ -0,0 +1,24 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// radar 7509234
@protocol Foo
@property (readonly, copy) id foos;
@end
@interface Bar <Foo> {
}
@end
@interface Baz <Foo> {
}
@end
@interface Bar ()
@property (readwrite, copy) id foos;
@end
@interface Baz ()
@property (readwrite, copy) id foos;
@end