r186936 - Correcting the NSObject and Overloadable attribute diagnostics so that the count reported matches reality.

Aaron Ballman aaron at aaronballman.com
Tue Jul 23 05:13:14 PDT 2013


Author: aaronballman
Date: Tue Jul 23 07:13:14 2013
New Revision: 186936

URL: http://llvm.org/viewvc/llvm-project?rev=186936&view=rev
Log:
Correcting the NSObject and Overloadable attribute diagnostics so that the count reported matches reality.

Modified:
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/Sema/overloadable.c
    cfe/trunk/test/SemaObjC/nsobject-attribute.m

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=186936&r1=186935&r2=186936&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Jul 23 07:13:14 2013
@@ -2499,10 +2499,8 @@ static void handleObjCExceptionAttr(Sema
 }
 
 static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
+  if (!checkAttributeNumArgs(S, Attr, 0))
     return;
-  }
   if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) {
     QualType T = TD->getUnderlyingType();
     if (!T->isCARCBridgableType()) {
@@ -2533,10 +2531,8 @@ static void handleObjCNSObject(Sema &S,
 
 static void
 handleOverloadableAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
+  if (!checkAttributeNumArgs(S, Attr, 0))
     return;
-  }
 
   if (!isa<FunctionDecl>(D)) {
     S.Diag(Attr.getLoc(), diag::err_attribute_overloadable_not_function);

Modified: cfe/trunk/test/Sema/overloadable.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/overloadable.c?rev=186936&r1=186935&r2=186936&view=diff
==============================================================================
--- cfe/trunk/test/Sema/overloadable.c (original)
+++ cfe/trunk/test/Sema/overloadable.c Tue Jul 23 07:13:14 2013
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute can only be applied to a function}}
+void params(void) __attribute__((overloadable(12))); // expected-error {{attribute takes no arguments}}
 
 int *f(int) __attribute__((overloadable)); // expected-note 2{{previous overload of function is here}}
 float *f(float); // expected-error{{overloaded function 'f' must have the 'overloadable' attribute}}

Modified: cfe/trunk/test/SemaObjC/nsobject-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nsobject-attribute.m?rev=186936&r1=186935&r2=186936&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/nsobject-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/nsobject-attribute.m Tue Jul 23 07:13:14 2013
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
 
 typedef struct CGColor * __attribute__ ((NSObject)) CGColorRef;
+typedef struct CGColor * __attribute__((NSObject(12))) Illegal;  // expected-error {{attribute takes no arguments}}
+
 static int count;
 static CGColorRef tmp = 0;
 





More information about the cfe-commits mailing list