]> granicus.if.org Git - clang/commitdiff
Making some attribute diagnostics more consistent. Removes a newly-unused diagnostic.
authorAaron Ballman <aaron@aaronballman.com>
Sun, 24 Nov 2013 20:36:50 +0000 (20:36 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Sun, 24 Nov 2013 20:36:50 +0000 (20:36 +0000)
Reviewed by Fariborz Jahanian

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

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

index 8f2903aaef4b6e323a67e238c83f08bcf3c40f4e..bf81169b7f8e46646da37bc583e811af1e03f6d8 100644 (file)
@@ -1796,9 +1796,6 @@ def err_attribute_wrong_number_arguments : Error<
   ":requires exactly %1 arguments}1">;
 def err_attribute_too_many_arguments : Error<
   "attribute takes no more than %0 argument%s0">;
-def err_suppress_autosynthesis : Error<
-  "objc_requires_property_definitions 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_invalid_vector_type : Error<"invalid vector element type %0">;
index 5a0b72fcb50b686e0ac8332340027ff05b5ab5dd..76cbaa297f13531e8aab85e0bb639840c96362b4 100644 (file)
@@ -2116,6 +2116,11 @@ static void handleAttrWithMessage(Sema &S, Decl *D,
 
 static void handleArcWeakrefUnavailableAttr(Sema &S, Decl *D, 
                                             const AttributeList &Attr) {
+  if (!isa<ObjCInterfaceDecl>(D)) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
+      << Attr.getName() << ExpectedObjectiveCInterface;
+    return;
+  }
   D->addAttr(::new (S.Context)
              ArcWeakrefUnavailableAttr(Attr.getRange(), S.Context,
                                        Attr.getAttributeSpellingListIndex()));
@@ -2158,7 +2163,8 @@ static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D,
 static void handleObjCRequiresPropertyDefsAttr(Sema &S, Decl *D,
                                                const AttributeList &Attr) {
   if (!isa<ObjCInterfaceDecl>(D)) {
-    S.Diag(Attr.getLoc(), diag::err_suppress_autosynthesis);
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
+      << Attr.getName() << ExpectedObjectiveCInterface;
     return;
   }
   
index eab5f2ca746e44df045ec6f1fc3fb86ea70fec51..82748027435e3c03d9ee60036ab5133adb5c5e8f 100644 (file)
@@ -90,3 +90,5 @@ __attribute__((objc_arc_weak_reference_unavailable))
 __attribute__((objc_arc_weak_reference_unavailable(1)))        // expected-error {{'objc_arc_weak_reference_unavailable' attribute takes no arguments}}
 @interface I3
 @end
+
+int I4 __attribute__((objc_arc_weak_reference_unavailable)); // expected-error {{'objc_arc_weak_reference_unavailable' attribute only applies to Objective-C interfaces}}
index 1c32665a2dd75673eae9e7cd714356154d3e3078..0275806dd0e5a6c1c820f79bd2f00282d9c963b7 100644 (file)
@@ -37,7 +37,7 @@ __attribute ((objc_requires_property_definitions))
 @interface Deep(CAT)  // expected-error {{attributes may not be specified on a category}}
 @end
 
-__attribute ((objc_requires_property_definitions)) // expected-error {{objc_requires_property_definitions attribute may only be specified on a class}} 
+__attribute ((objc_requires_property_definitions)) // expected-error {{'objc_requires_property_definitions' attribute only applies to Objective-C interfaces}}
 @protocol P @end
 
 // rdar://13388503