]> granicus.if.org Git - clang/commitdiff
Correcting the NSObject and Overloadable attribute diagnostics so that the count...
authorAaron Ballman <aaron@aaronballman.com>
Tue, 23 Jul 2013 12:13:14 +0000 (12:13 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Tue, 23 Jul 2013 12:13:14 +0000 (12:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186936 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/Sema/overloadable.c
test/SemaObjC/nsobject-attribute.m

index a3e05e69d2a732474f6b852caf3d591e0c6d1b63..807978726c237a0febb5b3be967048f0b93cfee6 100644 (file)
@@ -2499,10 +2499,8 @@ static void handleObjCExceptionAttr(Sema &S, Decl *D,
 }
 
 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, Decl *D, const AttributeList &Attr) {
 
 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);
index ad021898f2a0e744845728bc8688b056afd26684..076e05e91a288526d8ad04304176fcf08f61b4ea 100644 (file)
@@ -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}}
index b794eafc9ed7926e2dc309a298049a8e390132c9..64fa83884a5af076d54e4f4be0b560d69458a12a 100644 (file)
@@ -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;