r195578 - Making some attribute diagnostics more consistent. Removes a newly-unused diagnostic.

Aaron Ballman aaron at aaronballman.com
Sun Nov 24 12:36:50 PST 2013


Author: aaronballman
Date: Sun Nov 24 14:36:50 2013
New Revision: 195578

URL: http://llvm.org/viewvc/llvm-project?rev=195578&view=rev
Log:
Making some attribute diagnostics more consistent. Removes a newly-unused diagnostic.

Reviewed by Fariborz Jahanian

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=195578&r1=195577&r2=195578&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Nov 24 14:36:50 2013
@@ -1796,9 +1796,6 @@ def err_attribute_wrong_number_arguments
   ":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">;

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=195578&r1=195577&r2=195578&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sun Nov 24 14:36:50 2013
@@ -2116,6 +2116,11 @@ static void handleAttrWithMessage(Sema &
 
 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 handleObjCSuppresProtocolAtt
 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;
   }
   

Modified: cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m?rev=195578&r1=195577&r2=195578&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m (original)
+++ cfe/trunk/test/SemaObjC/arc-unavailable-for-weakref.m Sun Nov 24 14:36:50 2013
@@ -90,3 +90,5 @@ __attribute__((objc_arc_weak_reference_u
 __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}}

Modified: cfe/trunk/test/SemaObjC/default-synthesize-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/default-synthesize-3.m?rev=195578&r1=195577&r2=195578&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/default-synthesize-3.m (original)
+++ cfe/trunk/test/SemaObjC/default-synthesize-3.m Sun Nov 24 14:36:50 2013
@@ -37,7 +37,7 @@ __attribute ((objc_requires_property_def
 @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





More information about the cfe-commits mailing list