]> granicus.if.org Git - clang/commitdiff
Updated the wording of two attribute-related diagnostics so that they print the offen...
authorAaron Ballman <aaron@aaronballman.com>
Thu, 2 Jan 2014 21:26:14 +0000 (21:26 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Thu, 2 Jan 2014 21:26:14 +0000 (21:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198355 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
lib/Sema/TargetAttributesSema.cpp
test/Sema/arm-interrupt-attr.c
test/Sema/attr-ownership.c
test/Sema/constructor-attribute.c
test/Sema/sentinel-attribute.c
test/SemaCUDA/launch_bounds.cu
test/SemaCXX/warn-consumed-parsing.cpp
test/SemaCXX/warn-thread-safety-parsing.cpp
test/SemaObjC/method-sentinel-attr.m

index 036d8555ce133f72be6bf241588713b1a8db53d5..d8528c00de988c560c6d3504bb756714501ee8b0 100644 (file)
@@ -1804,9 +1804,9 @@ def err_attribute_wrong_number_arguments : Error<
   "%0 attribute %plural{0:takes no arguments|1:takes one argument|"
   ":requires exactly %1 arguments}1">;
 def err_attribute_too_many_arguments : Error<
-  "attribute takes no more than %0 argument%s0">;
+  "%0 attribute takes no more than %1 argument%s1">;
 def err_attribute_too_few_arguments : Error<
-  "attribute takes at least %0 argument%s0">;
+  "%0 attribute takes at least %1 argument%s1">;
 def err_attribute_invalid_vector_type : Error<"invalid vector element type %0">;
 def err_attribute_bad_neon_vector_size : Error<
   "Neon vector size must be 64 or 128 bits">;
index aaaa2b3552cbac9125814e8cac474ec6816ee801..8a9806586d9008692bd525d134ec7930d99f1a50 100644 (file)
@@ -211,7 +211,8 @@ static bool checkAttributeNumArgs(Sema &S, const AttributeList &Attr,
 static bool checkAttributeAtLeastNumArgs(Sema &S, const AttributeList &Attr,
                                          unsigned Num) {
   if (getNumAttributeArgs(Attr) < Num) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_few_arguments) << Num;
+    S.Diag(Attr.getLoc(), diag::err_attribute_too_few_arguments)
+      << Attr.getName() << Num;
     return false;
   }
 
@@ -1264,13 +1265,15 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) {
   case OwnershipAttr::Takes:
   case OwnershipAttr::Holds:
     if (AL.getNumArgs() < 2) {
-      S.Diag(AL.getLoc(), diag::err_attribute_too_few_arguments) << 2;
+      S.Diag(AL.getLoc(), diag::err_attribute_too_few_arguments)
+        << AL.getName() << 2;
       return;
     }
     break;
   case OwnershipAttr::Returns:
     if (AL.getNumArgs() > 2) {
-      S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << 1;
+      S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments)
+        << AL.getName() << 1;
       return;
     }
     break;
@@ -1639,7 +1642,8 @@ static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
 static void handleConstructorAttr(Sema &S, Decl *D, const AttributeList &Attr) {
   // check the attribute arguments.
   if (Attr.getNumArgs() > 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 1;
+    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
+      << Attr.getName() << 1;
     return;
   }
 
@@ -1656,7 +1660,8 @@ static void handleConstructorAttr(Sema &S, Decl *D, const AttributeList &Attr) {
 static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &Attr) {
   // check the attribute arguments.
   if (Attr.getNumArgs() > 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 1;
+    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
+      << Attr.getName() << 1;
     return;
   }
 
@@ -1675,7 +1680,8 @@ static void handleAttrWithMessage(Sema &S, Decl *D,
                                   const AttributeList &Attr) {
   unsigned NumArgs = Attr.getNumArgs();
   if (NumArgs > 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 1;
+    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
+      << Attr.getName() << 1;
     return;
   }
 
@@ -2079,7 +2085,8 @@ static void handleBlocksAttr(Sema &S, Decl *D, const AttributeList &Attr) {
 static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
   // check the attribute arguments.
   if (Attr.getNumArgs() > 2) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 2;
+    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
+      << Attr.getName() << 2;
     return;
   }
 
@@ -3284,7 +3291,8 @@ static void handleLaunchBoundsAttr(Sema &S, Decl *D,
   // check the attribute arguments.
   if (Attr.getNumArgs() != 1 && Attr.getNumArgs() != 2) {
     // FIXME: 0 is not okay.
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 2;
+    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
+      << Attr.getName() << 2;
     return;
   }
 
index 65173bc78ccc8c3e966b2e13720beb6b6a2f24f6..b70b15c37b24268d891dae980b59f1727ae51e68 100644 (file)
@@ -31,7 +31,7 @@ static void HandleARMInterruptAttr(Decl *d,
   // Check the attribute arguments.
   if (Attr.getNumArgs() > 1) {
     S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
-        << 1;
+      << Attr.getName() << 1;
     return;
   }
 
index b2cedc2e4d203d5e1cce16543ce3b205ecf3f4be..e8f21ada7fc1b7704a6328a8429ac4abe3802781 100644 (file)
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 %s -triple arm-apple-darwin -verify -fsyntax-only
 
-__attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}} 
+__attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}}
 __attribute__((interrupt("irq"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: irq}}
 
-__attribute__((interrupt("IRQ", 1))) void foo2() {} // expected-error {{attribute takes no more than 1 argument}}
+__attribute__((interrupt("IRQ", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
 
 __attribute__((interrupt("IRQ"))) void foo3() {}
 __attribute__((interrupt("FIQ"))) void foo4() {}
index e31b429ef6ed1fc3d978320f8cdeeabc242aafef..2aa9f9f27cc999cf439f1fab3160b3a5479d6ad1 100644 (file)
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 %s -verify
 
 void f1(void) __attribute__((ownership_takes("foo"))); // expected-error {{'ownership_takes' attribute requires parameter 1 to be an identifier}}
-void *f2(void) __attribute__((ownership_returns(foo, 1, 2)));  // expected-error {{attribute takes no more than 1 argument}}
+void *f2(void) __attribute__((ownership_returns(foo, 1, 2)));  // expected-error {{'ownership_returns' attribute takes no more than 1 argument}}
 void f3(void) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
 void *f4(void) __attribute__((ownership_returns(foo)));
-void f5(void) __attribute__((ownership_holds(foo)));  // expected-error {{attribute takes at least 2 arguments}}
+void f5(void) __attribute__((ownership_holds(foo)));  // expected-error {{'ownership_holds' attribute takes at least 2 arguments}}
 void f6(void) __attribute__((ownership_holds(foo, 1, 2, 3)));  // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
-void f7(void) __attribute__((ownership_takes(foo)));  // expected-error {{attribute takes at least 2 arguments}}
+void f7(void) __attribute__((ownership_takes(foo)));  // expected-error {{'ownership_takes' attribute takes at least 2 arguments}}
 void f8(int *i, int *j, int k) __attribute__((ownership_holds(foo, 1, 2, 4)));  // expected-error {{'ownership_holds' attribute parameter 3 is out of bounds}}
 
 int f9 __attribute__((ownership_takes(foo, 1)));  // expected-warning {{'ownership_takes' attribute only applies to functions}}
index 6a950979d36f172247ff42cfda65be7bd7ac7e82..1bb69fc4aa56b39562ecc554fb90b650a85d09da 100644 (file)
@@ -3,13 +3,13 @@
 int x __attribute__((constructor)); // expected-warning {{'constructor' attribute only applies to functions}}
 int f() __attribute__((constructor));
 int f() __attribute__((constructor(1)));
-int f() __attribute__((constructor(1,2))); // expected-error {{attribute takes no more than 1 argument}}
+int f() __attribute__((constructor(1,2))); // expected-error {{'constructor' attribute takes no more than 1 argument}}
 int f() __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires an integer constant}}
 
 int x __attribute__((destructor)); // expected-warning {{'destructor' attribute only applies to functions}}
 int f() __attribute__((destructor));
 int f() __attribute__((destructor(1)));
-int f() __attribute__((destructor(1,2))); // expected-error {{attribute takes no more than 1 argument}}
+int f() __attribute__((destructor(1,2))); // expected-error {{'destructor' attribute takes no more than 1 argument}}
 int f() __attribute__((destructor(1.0))); // expected-error {{'destructor' attribute requires an integer constant}}
 
 
index e5cbf6ee04af558eaa4f6267b7533f55528fa7ea..46f135041c1fc261b3b2e034c53af96aefe39dca 100644 (file)
@@ -5,7 +5,7 @@ void f1(int a, ...) __attribute__ ((sentinel));
 void f2(int a, ...) __attribute__ ((sentinel(1)));
 
 void f3(int a, ...) __attribute__ ((sentinel("hello"))); //expected-error{{'sentinel' attribute requires parameter 1 to be an integer constant}}
-void f4(int a, ...) __attribute__ ((sentinel(1, 2, 3))); //expected-error{{attribute takes no more than 2 arguments}}
+void f4(int a, ...) __attribute__ ((sentinel(1, 2, 3))); //expected-error{{'sentinel' attribute takes no more than 2 arguments}}
 void f4(int a, ...) __attribute__ ((sentinel(-1))); //expected-error{{parameter 1 less than zero}}
 void f4(int a, ...) __attribute__ ((sentinel(0, 2))); // expected-error{{parameter 2 not 0 or 1}}
 
index c508a00c2dd0ab2171c60d75074a5a840ba7d2ae..a1a4e64f1ca8fb772ec71ad138896b99b70ce2b1 100644 (file)
@@ -5,10 +5,10 @@
 __launch_bounds__(128, 7) void Test1(void);\r
 __launch_bounds__(128) void Test2(void);\r
 \r
-__launch_bounds__(1, 2, 3) void Test3(void); // expected-error {{attribute takes no more than 2 arguments}}\r
+__launch_bounds__(1, 2, 3) void Test3(void); // expected-error {{'launch_bounds' attribute takes no more than 2 arguments}}\r
 \r
 // FIXME: the error should read that the attribute takes exactly one or two arguments, but there\r
 // is no support for such a diagnostic currently.\r
-__launch_bounds__() void Test4(void); // expected-error {{attribute takes no more than 2 arguments}}\r
+__launch_bounds__() void Test4(void); // expected-error {{'launch_bounds' attribute takes no more than 2 arguments}}\r
 \r
 int Test5 __launch_bounds__(128, 7); // expected-warning {{'launch_bounds' attribute only applies to functions and methods}}\r
index 0a91636ea9492cf27ca074dcc1c38369a2ebac43..cfd3d3b71dd9cbd969c2af32edcdac1d0521d0cc 100644 (file)
@@ -17,9 +17,9 @@ int returnTypestateForUnconsumable() {
 }
 
 class AttrTester0 {
-  void consumes()       __attribute__ ((set_typestate())); // expected-error {{attribute takes one argument}}
-  bool testUnconsumed() __attribute__ ((test_typestate())); // expected-error {{attribute takes one argument}}
-  void callableWhen()   __attribute__ ((callable_when())); // expected-error {{attribute takes at least 1 argument}}
+  void consumes()       __attribute__ ((set_typestate())); // expected-error {{'set_typestate' attribute takes one argument}}
+  bool testUnconsumed() __attribute__ ((test_typestate())); // expected-error {{'test_typestate' attribute takes one argument}}
+  void callableWhen()   __attribute__ ((callable_when())); // expected-error {{'callable_when' attribute takes at least 1 argument}}
 };
 
 int var0 SET_TYPESTATE(consumed); // expected-warning {{'set_typestate' attribute only applies to methods}}
index c7678581dbf4f6fc666b82d6d230ef3579d63110..c221f1b35365e42251b3db0996ab38da9c296b51 100644 (file)
@@ -446,12 +446,12 @@ int * pgb_var_arg_bad_4 PT_GUARDED_BY(umu); // \
 Mutex mu_aa ACQUIRED_AFTER(mu1);
 
 Mutex aa_var_noargs __attribute__((acquired_after)); // \
-  // expected-error {{attribute takes at least 1 argument}}
+  // expected-error {{'acquired_after' attribute takes at least 1 argument}}
 
 class AAFoo {
  private:
   Mutex aa_field_noargs __attribute__((acquired_after)); // \
-    // expected-error {{attribute takes at least 1 argument}}
+    // expected-error {{'acquired_after' attribute takes at least 1 argument}}
   Mutex aa_field_args ACQUIRED_AFTER(mu1);
 };
 
@@ -506,12 +506,12 @@ UnlockableMu aa_var_arg_bad_5 ACQUIRED_AFTER(mu_aa); // \
 Mutex mu_ab ACQUIRED_BEFORE(mu1);
 
 Mutex ab_var_noargs __attribute__((acquired_before)); // \
-  // expected-error {{attribute takes at least 1 argument}}
+  // expected-error {{'acquired_before' attribute takes at least 1 argument}}
 
 class ABFoo {
  private:
   Mutex ab_field_noargs __attribute__((acquired_before)); // \
-    // expected-error {{attribute takes at least 1 argument}}
+    // expected-error {{'acquired_before' attribute takes at least 1 argument}}
   Mutex ab_field_args ACQUIRED_BEFORE(mu1);
 };
 
@@ -715,7 +715,7 @@ int slf_function_bad_7() SHARED_LOCK_FUNCTION(0); // \
 // plus an optional list of locks (vars/fields)
 
 void etf_function() __attribute__((exclusive_trylock_function));  // \
-  // expected-error {{attribute takes at least 1 argument}}
+  // expected-error {{'exclusive_trylock_function' attribute takes at least 1 argument}}
 
 void etf_function_args() EXCLUSIVE_TRYLOCK_FUNCTION(1, mu2);
 
@@ -788,7 +788,7 @@ int etf_function_bad_6() EXCLUSIVE_TRYLOCK_FUNCTION(1, umu); // \
 // plus an optional list of locks (vars/fields)
 
 void stf_function() __attribute__((shared_trylock_function));  // \
-  // expected-error {{attribute takes at least 1 argument}}
+  // expected-error {{'shared_trylock_function' attribute takes at least 1 argument}}
 
 void stf_function_args() SHARED_TRYLOCK_FUNCTION(1, mu2);
 
@@ -1001,7 +1001,7 @@ int lr_function_bad_4() LOCK_RETURNED(umu); // \
 // takes one or more arguments, all locks (vars/fields)
 
 void le_function() __attribute__((locks_excluded)); // \
-  // expected-error {{attribute takes at least 1 argument}}
+  // expected-error {{'locks_excluded' attribute takes at least 1 argument}}
 
 void le_function_arg() LOCKS_EXCLUDED(mu1);
 
@@ -1068,7 +1068,7 @@ int le_function_bad_4() LOCKS_EXCLUDED(umu); // \
 // takes one or more arguments, all locks (vars/fields)
 
 void elr_function() __attribute__((exclusive_locks_required)); // \
-  // expected-error {{attribute takes at least 1 argument}}
+  // expected-error {{'exclusive_locks_required' attribute takes at least 1 argument}}
 
 void elr_function_arg() EXCLUSIVE_LOCKS_REQUIRED(mu1);
 
@@ -1136,7 +1136,7 @@ int elr_function_bad_4() EXCLUSIVE_LOCKS_REQUIRED(umu); // \
 // takes one or more arguments, all locks (vars/fields)
 
 void slr_function() __attribute__((shared_locks_required)); // \
-  // expected-error {{attribute takes at least 1 argument}}
+  // expected-error {{'shared_locks_required' attribute takes at least 1 argument}}
 
 void slr_function_arg() SHARED_LOCKS_REQUIRED(mu1);
 
index d230be5805be6098801c29bed872fc9abc0f7a80..82ee373c2feffeb511752e0c830cbd83bd63f3f1 100644 (file)
@@ -13,7 +13,7 @@
 - (void) foo8 : (int)x, ... __attribute__ ((__sentinel__("a")));  // expected-error {{'__sentinel__' attribute requires parameter 1 to be an integer constant}}
 - (void) foo9 : (int)x, ... __attribute__ ((__sentinel__(-1)));  // expected-error {{'sentinel' parameter 1 less than zero}}
 - (void) foo10 : (int)x, ... __attribute__ ((__sentinel__(1,1)));
-- (void) foo11 : (int)x, ... __attribute__ ((__sentinel__(1,1,3)));  // expected-error {{attribute takes no more than 2 arguments}}
+- (void) foo11 : (int)x, ... __attribute__ ((__sentinel__(1,1,3)));  // expected-error {{'__sentinel__' attribute takes no more than 2 arguments}}
 - (void) foo12 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}}
 
 // rdar://7975788