diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2014-01-02 21:26:14 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2014-01-02 21:26:14 +0000 |
| commit | 05e420abad1fb8e7f01402dd43e16d578855dd17 (patch) | |
| tree | 8a006aec09fb93933502322a0e1b58f58d3a4e45 | |
| parent | decb024c86638ade1db1dafabad5e216a75a23b7 (diff) | |
| download | bcm5719-llvm-05e420abad1fb8e7f01402dd43e16d578855dd17.tar.gz bcm5719-llvm-05e420abad1fb8e7f01402dd43e16d578855dd17.zip | |
Updated the wording of two attribute-related diagnostics so that they print the offending attribute name. Also updates the associated test cases.
llvm-svn: 198355
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 24 | ||||
| -rw-r--r-- | clang/lib/Sema/TargetAttributesSema.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Sema/arm-interrupt-attr.c | 4 | ||||
| -rw-r--r-- | clang/test/Sema/attr-ownership.c | 6 | ||||
| -rw-r--r-- | clang/test/Sema/constructor-attribute.c | 4 | ||||
| -rw-r--r-- | clang/test/Sema/sentinel-attribute.c | 2 | ||||
| -rw-r--r-- | clang/test/SemaCUDA/launch_bounds.cu | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-consumed-parsing.cpp | 6 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-thread-safety-parsing.cpp | 18 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-sentinel-attr.m | 2 |
11 files changed, 42 insertions, 34 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 036d8555ce1..d8528c00de9 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -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">; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index aaaa2b3552c..8a9806586d9 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -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; } diff --git a/clang/lib/Sema/TargetAttributesSema.cpp b/clang/lib/Sema/TargetAttributesSema.cpp index 65173bc78cc..b70b15c37b2 100644 --- a/clang/lib/Sema/TargetAttributesSema.cpp +++ b/clang/lib/Sema/TargetAttributesSema.cpp @@ -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; } diff --git a/clang/test/Sema/arm-interrupt-attr.c b/clang/test/Sema/arm-interrupt-attr.c index b2cedc2e4d2..e8f21ada7fc 100644 --- a/clang/test/Sema/arm-interrupt-attr.c +++ b/clang/test/Sema/arm-interrupt-attr.c @@ -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() {} diff --git a/clang/test/Sema/attr-ownership.c b/clang/test/Sema/attr-ownership.c index e31b429ef6e..2aa9f9f27cc 100644 --- a/clang/test/Sema/attr-ownership.c +++ b/clang/test/Sema/attr-ownership.c @@ -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}} diff --git a/clang/test/Sema/constructor-attribute.c b/clang/test/Sema/constructor-attribute.c index 6a950979d36..1bb69fc4aa5 100644 --- a/clang/test/Sema/constructor-attribute.c +++ b/clang/test/Sema/constructor-attribute.c @@ -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}} diff --git a/clang/test/Sema/sentinel-attribute.c b/clang/test/Sema/sentinel-attribute.c index e5cbf6ee04a..46f135041c1 100644 --- a/clang/test/Sema/sentinel-attribute.c +++ b/clang/test/Sema/sentinel-attribute.c @@ -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}} diff --git a/clang/test/SemaCUDA/launch_bounds.cu b/clang/test/SemaCUDA/launch_bounds.cu index c508a00c2dd..a1a4e64f1ca 100644 --- a/clang/test/SemaCUDA/launch_bounds.cu +++ b/clang/test/SemaCUDA/launch_bounds.cu @@ -5,10 +5,10 @@ __launch_bounds__(128, 7) void Test1(void);
__launch_bounds__(128) void Test2(void);
-__launch_bounds__(1, 2, 3) void Test3(void); // expected-error {{attribute takes no more than 2 arguments}}
+__launch_bounds__(1, 2, 3) void Test3(void); // expected-error {{'launch_bounds' attribute takes no more than 2 arguments}}
// FIXME: the error should read that the attribute takes exactly one or two arguments, but there
// is no support for such a diagnostic currently.
-__launch_bounds__() void Test4(void); // expected-error {{attribute takes no more than 2 arguments}}
+__launch_bounds__() void Test4(void); // expected-error {{'launch_bounds' attribute takes no more than 2 arguments}}
int Test5 __launch_bounds__(128, 7); // expected-warning {{'launch_bounds' attribute only applies to functions and methods}}
diff --git a/clang/test/SemaCXX/warn-consumed-parsing.cpp b/clang/test/SemaCXX/warn-consumed-parsing.cpp index 0a91636ea94..cfd3d3b71dd 100644 --- a/clang/test/SemaCXX/warn-consumed-parsing.cpp +++ b/clang/test/SemaCXX/warn-consumed-parsing.cpp @@ -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}} diff --git a/clang/test/SemaCXX/warn-thread-safety-parsing.cpp b/clang/test/SemaCXX/warn-thread-safety-parsing.cpp index c7678581dbf..c221f1b3536 100644 --- a/clang/test/SemaCXX/warn-thread-safety-parsing.cpp +++ b/clang/test/SemaCXX/warn-thread-safety-parsing.cpp @@ -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); diff --git a/clang/test/SemaObjC/method-sentinel-attr.m b/clang/test/SemaObjC/method-sentinel-attr.m index d230be5805b..82ee373c2fe 100644 --- a/clang/test/SemaObjC/method-sentinel-attr.m +++ b/clang/test/SemaObjC/method-sentinel-attr.m @@ -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 |

