objc: use objc_suppress_autosynthesis attribute on classes

which should not be default synthesized.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147468 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2012-01-03 19:46:00 +00:00
Родитель c13a34b690
Коммит eb4f2c56c2
3 изменённых файлов: 41 добавлений и 5 удалений

Просмотреть файл

@ -1665,8 +1665,9 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
// Check and see if properties declared in the interface have either 1)
// an implementation or 2) there is a @synthesize/@dynamic implementation
// of the property in the @implementation.
if (isa<ObjCInterfaceDecl>(CDecl) &&
!(LangOpts.ObjCDefaultSynthProperties && LangOpts.ObjCNonFragileABI2))
if (const ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl))
if (!(LangOpts.ObjCDefaultSynthProperties && LangOpts.ObjCNonFragileABI2) ||
IDecl->isObjCSuppressAutosynthesis())
DiagnoseUnimplementedProperties(S, IMPDecl, CDecl, InsMap);
llvm::DenseSet<Selector> ClsMap;

Просмотреть файл

@ -856,7 +856,8 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
}
IC->addPropertyImplementation(PIDecl);
if (getLangOptions().ObjCDefaultSynthProperties &&
getLangOptions().ObjCNonFragileABI2) {
getLangOptions().ObjCNonFragileABI2 &&
!IDecl->isObjCSuppressAutosynthesis()) {
// Diagnose if an ivar was lazily synthesdized due to a previous
// use and if 1) property is @dynamic or 2) property is synthesized
// but it requires an ivar of different name.
@ -1355,6 +1356,7 @@ void Sema::DefaultSynthesizeProperties(Scope *S, Decl *D) {
if (!IC)
return;
if (ObjCInterfaceDecl* IDecl = IC->getClassInterface())
if (!IDecl->isObjCSuppressAutosynthesis())
DefaultSynthesizeProperties(S, IC, IDecl);
}

Просмотреть файл

@ -0,0 +1,33 @@
// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify %s
// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify %s
__attribute ((objc_suppress_autosynthesis))
@interface NoAuto
@property int NoAutoProp; // expected-note 2 {{property declared here}}
@end
@implementation NoAuto // expected-warning {{property 'NoAutoProp' requires method 'NoAutoProp' to be defined}} \
// expected-warning {{property 'NoAutoProp' requires method 'setNoAutoProp:'}}
@end
__attribute ((objc_suppress_autosynthesis)) // redundant, just for testing
@interface Sub : NoAuto
@property (copy) id SubProperty; // expected-note 2 {{property declared here}}
@end
@implementation Sub // expected-warning {{property 'SubProperty' requires method 'SubProperty' to be defined}} \
// expected-warning {{property 'SubProperty' requires method 'setSubProperty:' to be defined}}
@end
@interface Deep : Sub
@property (copy) id DeepProperty;
@property (copy) id DeepSynthProperty;
@property (copy) id DeepMustSynthProperty; // expected-note {{property declared here}}
@end
@implementation Deep // expected-warning {{property 'DeepMustSynthProperty' requires method 'setDeepMustSynthProperty:' to be defined}}
@dynamic DeepProperty;
@synthesize DeepSynthProperty;
- (id) DeepMustSynthProperty { return 0; }
@end