зеркало из https://github.com/microsoft/clang-1.git
Fix a bug when property is redeclared in multiple
continuation classes and its original declaration is imported from a protocol. This fixes radar 7509234. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92856 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
4b0f21c0f8
Коммит
b73e281956
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
Загрузка…
Ссылка в новой задаче