From: John McCall Date: Tue, 25 Jan 2011 03:51:08 +0000 (+0000) Subject: Change the wording of the bad-decl-for-attribute warning and error X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d6b8de0e7b01196bd2bee207feb81bc409a5baf9;p=clang Change the wording of the bad-decl-for-attribute warning and error to make it clear that we're talking about the declarations and not the types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124175 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index e29d098d82..e31842da4e 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1038,17 +1038,17 @@ def err_attribute_weakref_without_alias : Error< def err_alias_not_supported_on_darwin : Error < "only weak aliases are supported on darwin">; def warn_attribute_wrong_decl_type : Warning< - "%0 attribute only applies to %select{function|union|" - "variable and function|function or method|parameter|" - "parameter or Objective-C method|function, method or block|" - "virtual method or class|function, method, or parameter|class|virtual method" - "|member|variable|method}1 types">; + "%0 attribute only applies to %select{functions|unions|" + "variables and functions|functions and methods|parameters|" + "parameters and methods|functions, methods and blocks|" + "classes and virtual methods|functions, methods, and parameters|" + "classes|virtual methods|class members|variables|methods}1">; def err_attribute_wrong_decl_type : Error< - "%0 attribute only applies to %select{function|union|" - "variable and function|function or method|parameter|" - "parameter or Objective-C method|function, method or block|" - "virtual method or class|function, method, or parameter|class|virtual method" - "|member|variable|method}1 types">; + "%0 attribute only applies to %select{functions|unions|" + "variables and functions|functions and methods|parameters|" + "parameters and methods|functions, methods and blocks|" + "classes and virtual methods|functions, methods, and parameters|" + "classes|virtual methods|class members|variables|methods}1">; def warn_function_attribute_wrong_type : Warning< "%0 only applies to function types; type here is %1">; def warn_gnu_inline_attribute_requires_inline : Warning< diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index ac136cb298..eefd132282 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -1213,7 +1213,7 @@ typedef NSString* MyStringTy; - (int) returnsAnOwnedInt NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to methods that return an Objective-C object}} @end -static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to function or method types}} +static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to functions and methods}} void test_attr_1(TestOwnershipAttr *X) { NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}} diff --git a/test/Rewriter/dllimport-typedef.c b/test/Rewriter/dllimport-typedef.c index 441f498668..72cea70cf2 100644 --- a/test/Rewriter/dllimport-typedef.c +++ b/test/Rewriter/dllimport-typedef.c @@ -11,7 +11,7 @@ void bar() { return 1; } // CHECK-NEG: error: void function 'bar' should not return a value // CHECK-NEG: 1 error generated -// CHECK-POS: warning: 'dllimport' attribute only applies to variable and function type +// CHECK-POS: warning: 'dllimport' attribute only applies to variables and functions // CHECK-POS: error: void function 'bar' should not return a value // CHECK-POS: 1 warning and 1 error generated diff --git a/test/Sema/attr-naked.c b/test/Sema/attr-naked.c index 7f181981f3..65d1726da1 100644 --- a/test/Sema/attr-naked.c +++ b/test/Sema/attr-naked.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only -int a __attribute__((naked)); // expected-warning {{'naked' attribute only applies to function types}} +int a __attribute__((naked)); // expected-warning {{'naked' attribute only applies to functions}} void t1() __attribute__((naked)); diff --git a/test/Sema/attr-nodebug.c b/test/Sema/attr-nodebug.c index 203c2a7300..6865de0602 100644 --- a/test/Sema/attr-nodebug.c +++ b/test/Sema/attr-nodebug.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only -int a __attribute__((nodebug)); // expected-warning {{'nodebug' attribute only applies to function types}} +int a __attribute__((nodebug)); // expected-warning {{'nodebug' attribute only applies to functions}} void t1() __attribute__((nodebug)); diff --git a/test/Sema/attr-noinline.c b/test/Sema/attr-noinline.c index 92dc9007eb..8c91b65b4f 100644 --- a/test/Sema/attr-noinline.c +++ b/test/Sema/attr-noinline.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only -int a __attribute__((noinline)); // expected-warning {{'noinline' attribute only applies to function types}} +int a __attribute__((noinline)); // expected-warning {{'noinline' attribute only applies to functions}} void t1() __attribute__((noinline)); diff --git a/test/Sema/attr-used.c b/test/Sema/attr-used.c index d50f4c09ac..0838816924 100644 --- a/test/Sema/attr-used.c +++ b/test/Sema/attr-used.c @@ -3,7 +3,7 @@ extern int l0 __attribute__((used)); // expected-warning {{used attribute ignored}} __private_extern__ int l1 __attribute__((used)); // expected-warning {{used attribute ignored}} -struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to variable and function types}} +struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to variables and functions}} int x; }; diff --git a/test/Sema/attr-weak.c b/test/Sema/attr-weak.c index 8e3e626c5d..2abe0682df 100644 --- a/test/Sema/attr-weak.c +++ b/test/Sema/attr-weak.c @@ -8,8 +8,8 @@ int __attribute__((weak_import)) g4(void); void __attribute__((weak_import)) g5(void) { } -struct __attribute__((weak)) s0 {}; // expected-warning {{'weak' attribute only applies to variable and function types}} -struct __attribute__((weak_import)) s1 {}; // expected-warning {{'weak_import' attribute only applies to variable and function types}} +struct __attribute__((weak)) s0 {}; // expected-warning {{'weak' attribute only applies to variables and functions}} +struct __attribute__((weak_import)) s1 {}; // expected-warning {{'weak_import' attribute only applies to variables and functions}} static int x __attribute__((weak)); // expected-error {{weak declaration of 'x' must be public}} diff --git a/test/Sema/constructor-attribute.c b/test/Sema/constructor-attribute.c index 3dfbbcbe28..2decebbd28 100644 --- a/test/Sema/constructor-attribute.c +++ b/test/Sema/constructor-attribute.c @@ -1,12 +1,12 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -int x __attribute__((constructor)); // expected-warning {{'constructor' attribute only applies to function types}} +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 requires 0 or 1 argument(s)}} int f() __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires parameter 1 to be an integer constant}} -int x __attribute__((destructor)); // expected-warning {{'destructor' attribute only applies to function types}} +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 requires 0 or 1 argument(s)}} diff --git a/test/Sema/dllimport-dllexport.c b/test/Sema/dllimport-dllexport.c index eea2f6fe96..f09e3cf69a 100644 --- a/test/Sema/dllimport-dllexport.c +++ b/test/Sema/dllimport-dllexport.c @@ -10,9 +10,9 @@ void __attribute__((dllimport, dllexport)) foo4(); // expected-warning{{dllimpor void __attribute__((dllexport)) foo5(); void __attribute__((dllimport)) foo5(); // expected-warning{{dllimport attribute ignored}} -typedef int __attribute__((dllexport)) type6; // expected-warning{{'dllexport' attribute only applies to variable and function types}} +typedef int __attribute__((dllexport)) type6; // expected-warning{{'dllexport' attribute only applies to variables and functions}} -typedef int __attribute__((dllimport)) type7; // expected-warning{{'dllimport' attribute only applies to variable and function}} +typedef int __attribute__((dllimport)) type7; // expected-warning{{'dllimport' attribute only applies to variables and functions}} void __attribute__((dllimport)) foo6(); void foo6(){} // expected-warning {{'foo6' redeclared without dllimport attribute: previous dllimport ignored}} @@ -28,9 +28,9 @@ void __declspec(dllimport) __declspec(dllexport) foo10(); // expected-warning{{d void __declspec(dllexport) foo11(); void __declspec(dllimport) foo11(); // expected-warning{{dllimport attribute ignored}} -typedef int __declspec(dllexport) type1; // expected-warning{{'dllexport' attribute only applies to variable and function types}} +typedef int __declspec(dllexport) type1; // expected-warning{{'dllexport' attribute only applies to variables and functions}} -typedef int __declspec(dllimport) type2; // expected-warning{{'dllimport' attribute only applies to variable and function}} +typedef int __declspec(dllimport) type2; // expected-warning{{'dllimport' attribute only applies to variables and functions}} void __declspec(dllimport) foo12(); void foo12(){} // expected-warning {{'foo12' redeclared without dllimport attribute: previous dllimport ignored}} diff --git a/test/Sema/sentinel-attribute.c b/test/Sema/sentinel-attribute.c index 4c09273967..ed0ef89db7 100644 --- a/test/Sema/sentinel-attribute.c +++ b/test/Sema/sentinel-attribute.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -int x __attribute__((sentinel)); //expected-warning{{'sentinel' attribute only applies to function, method or block types}} +int x __attribute__((sentinel)); //expected-warning{{'sentinel' attribute only applies to functions, methods and blocks}} void f1(int a, ...) __attribute__ ((sentinel)); void f2(int a, ...) __attribute__ ((sentinel(1))); diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c index 760e3cf8d3..9949887b23 100644 --- a/test/Sema/unused-expr.c +++ b/test/Sema/unused-expr.c @@ -95,7 +95,7 @@ int t6() { return 0; } -int t7 __attribute__ ((warn_unused_result)); // expected-warning {{'warn_unused_result' attribute only applies to function types}} +int t7 __attribute__ ((warn_unused_result)); // expected-warning {{'warn_unused_result' attribute only applies to functions}} // PR4010 int (*fn4)(void) __attribute__ ((warn_unused_result)); diff --git a/test/Sema/x86-attr-force-align-arg-pointer.c b/test/Sema/x86-attr-force-align-arg-pointer.c index b406a77e04..5d36e9af19 100644 --- a/test/Sema/x86-attr-force-align-arg-pointer.c +++ b/test/Sema/x86-attr-force-align-arg-pointer.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple i386-apple-darwin10 -fsyntax-only -verify %s -int a __attribute__((force_align_arg_pointer)); // expected-warning{{attribute only applies to function types}} +int a __attribute__((force_align_arg_pointer)); // expected-warning{{attribute only applies to functions}} // It doesn't matter where the attribute is located. void b(void) __attribute__((force_align_arg_pointer)); diff --git a/test/SemaObjC/format-arg-attribute.m b/test/SemaObjC/format-arg-attribute.m index 264e7a8179..98dff3aa7a 100644 --- a/test/SemaObjC/format-arg-attribute.m +++ b/test/SemaObjC/format-arg-attribute.m @@ -9,9 +9,9 @@ extern void fc1 (const NSString *) __attribute__((format_arg)); // expected-err extern void fc2 (const NSString *) __attribute__((format_arg())); // expected-error {{attribute requires 1 argument(s)}} extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expected-error {{attribute requires 1 argument(s)}} -struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}} -union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}} -enum e1 { E1V0 } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to function types}} +struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to functions}} +union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to functions}} +enum e1 { E1V0 } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to functions}} extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2))); extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{attribute requires 1 argument(s)}}