diff options
author | Faisal Vali <faisalv@yahoo.com> | 2017-12-25 22:23:20 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2017-12-25 22:23:20 +0000 |
commit | 059912d2c3725678160cf86157dd6637c7923698 (patch) | |
tree | 2ae8ed15c231364c98af4aded3ccf3d15e3d0b83 /test/Parser | |
parent | d0ee47a8ce602a6e61ac63fa668365a3a2469038 (diff) |
Add a fixit for attributes incorrectly placed prior to 'struct/class/enum' keyword.
Suggest moving the following erroneous attrib list (based on location)
[[]] struct X;
to
struct [[]] X;
Additionally, added a fixme for the current implementation that diagnoses misplaced attributes to consider using the newly introduced diagnostic (that I think is more user-friendly).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser')
-rw-r--r-- | test/Parser/c2x-attributes.c | 6 | ||||
-rw-r--r-- | test/Parser/cxx-decl.cpp | 2 | ||||
-rw-r--r-- | test/Parser/cxx0x-attributes.cpp | 9 |
3 files changed, 12 insertions, 5 deletions
diff --git a/test/Parser/c2x-attributes.c b/test/Parser/c2x-attributes.c index 1be69f1ca2..f261dee200 100644 --- a/test/Parser/c2x-attributes.c +++ b/test/Parser/c2x-attributes.c @@ -7,7 +7,7 @@ enum [[]] E { }; enum [[]] { Four }; -[[]] enum E2 { Five }; // expected-error {{an attribute list cannot appear here}} +[[]] enum E2 { Five }; // expected-error {{misplaced attributes}} // FIXME: this diagnostic can be improved. enum { [[]] Six }; // expected-error {{expected identifier}} @@ -24,7 +24,7 @@ struct [[]] S1 { int o [[]] : 12; }; -[[]] struct S2 { int a; }; // expected-error {{an attribute list cannot appear here}} +[[]] struct S2 { int a; }; // expected-error {{misplaced attributes}} struct S3 [[]] { int a; }; // expected-error {{an attribute list cannot appear here}} union [[]] U { @@ -32,7 +32,7 @@ union [[]] U { [[]] int i; }; -[[]] union U2 { double d; }; // expected-error {{an attribute list cannot appear here}} +[[]] union U2 { double d; }; // expected-error {{misplaced attributes}} union U3 [[]] { double d; }; // expected-error {{an attribute list cannot appear here}} struct [[]] IncompleteStruct; diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index 58ad08079c..1a24520b8f 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -199,7 +199,7 @@ namespace PR15017 { // expected-error@-2 {{expected expression}} // expected-error@-3 {{expected unqualified-id}} #else -// expected-error@-5 {{an attribute list cannot appear here}} +// expected-error@-5 {{misplaced attributes}} #endif namespace test7 { diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp index 4e3a2e4685..e01491db41 100644 --- a/test/Parser/cxx0x-attributes.cpp +++ b/test/Parser/cxx0x-attributes.cpp @@ -64,6 +64,13 @@ struct MemberFnOrder { struct [[]] struct_attr; class [[]] class_attr {}; union [[]] union_attr; +enum [[]] E { }; +namespace test_misplacement { +[[]] struct struct_attr2; //expected-error{{misplaced attributes}} +[[]] class class_attr2; //expected-error{{misplaced attributes}} +[[]] union union_attr2; //expected-error{{misplaced attributes}} +[[]] enum E2 { }; //expected-error{{misplaced attributes}} +} // Checks attributes placed at wrong syntactic locations of class specifiers. class [[]] [[]] @@ -91,7 +98,7 @@ class C final [[deprecated(l]] {}); // expected-error {{use of undeclared identi class D final alignas ([l) {}]{}); // expected-error {{expected ',' or ']' in lambda capture list}} expected-error {{an attribute list cannot appear here}} [[]] struct with_init_declarators {} init_declarator; -[[]] struct no_init_declarators; // expected-error {{an attribute list cannot appear here}} +[[]] struct no_init_declarators; // expected-error {{misplaced attributes}} template<typename> [[]] struct no_init_declarators_template; // expected-error {{an attribute list cannot appear here}} void fn_with_structs() { [[]] struct with_init_declarators {} init_declarator; |