]> granicus.if.org Git - clang/commitdiff
objc: diagnose misplacement of objc_suppress_autosynthesis
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Jan 2012 22:52:32 +0000 (22:52 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Jan 2012 22:52:32 +0000 (22:52 +0000)
attribute.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147490 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
test/SemaObjC/default-synthesize-3.m

index d97dff633bf321ce3ce048bae449d55d8a2fa125..7e5fff8ab4664a7900f88c38d8fe5695808a4421 100644 (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<
index 4074afee1cc659aabcfcc623f920cb473b24b0f6..22a2cfe8a6eb0763b6caa6837a53aa0516f41750 100644 (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;
index 7b07cb9aa172368da30c598f70ca4ca464b24e60..20e7dd28f293f82899832f79b9c20a8bec5ce365 100644 (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