objc: diagnose misplacement of objc_suppress_autosynthesis

attribute.

llvm-svn: 147490
This commit is contained in:
Fariborz Jahanian 2012-01-03 22:52:32 +00:00
parent 1ad2433690
commit 7249e36704
3 changed files with 14 additions and 0 deletions

View File

@ -1369,6 +1369,9 @@ def err_attribute_wrong_number_arguments : Error<
":requires exactly %0 arguments}0">;
def err_attribute_too_many_arguments : Error<
"attribute takes no more than %0 argument%s0">;
def err_suppress_autosynthesis : Error<
"objc_suppress_autosynthesis attribute may only be specified on a class"
"to a class declaration">;
def err_attribute_too_few_arguments : Error<
"attribute takes at least %0 argument%s0">;
def err_attribute_missing_parameter_name : Error<

View File

@ -1581,6 +1581,11 @@ static void handleArcWeakrefUnavailableAttr(Sema &S, Decl *D,
static void handleObjCSuppressAutosynthesisAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
if (!isa<ObjCInterfaceDecl>(D)) {
S.Diag(Attr.getLoc(), diag::err_suppress_autosynthesis);
return;
}
unsigned NumArgs = Attr.getNumArgs();
if (NumArgs > 0) {
S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 0;

View File

@ -31,3 +31,9 @@ __attribute ((objc_suppress_autosynthesis)) // redundant, just for testing
- (id) DeepMustSynthProperty { return 0; }
@end
__attribute ((objc_suppress_autosynthesis))
@interface Deep(CAT) // expected-error {{attributes may not be specified on a category}}
@end
__attribute ((objc_suppress_autosynthesis)) // expected-error {{objc_suppress_autosynthesis attribute may only be specified on a class}}
@protocol P @end