diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-12-29 21:56:22 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-12-29 21:56:22 +0000 |
commit | 36de3a25c2372d084ec329e66441c1fdadb4c727 (patch) | |
tree | 408920586a208c74a4a52bc91a50deb0b2fe5aa2 | |
parent | 651b72095b64a5add9e0f255bd8f6a5df6dfff07 (diff) | |
download | bcm5719-llvm-36de3a25c2372d084ec329e66441c1fdadb4c727.tar.gz bcm5719-llvm-36de3a25c2372d084ec329e66441c1fdadb4c727.zip |
Crash even less on malformed attributes in an incorrect location.
This is a follow-up to r224915. This adds a bit more line noise to the tests
added in that revision to make sure the parser is ready for a toplevel decl
after each incorrect line. Use this to move the tests up to where they belong.
This uncovered that the early return was missing a call to
ActOnTagDefinitionError(), so add that. (Also fixes at least one of the crashes
on SLi's bot.)
llvm-svn: 224958
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 5 | ||||
-rw-r--r-- | clang/test/Parser/cxx0x-attributes.cpp | 8 |
2 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 4377a782864..1c38979faef 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -2714,8 +2714,11 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, // attribute parsing code will try to parse the '[' as a constexpr lambda // and consume enough tokens that the alignas parsing code will eat the // opening '{'. So bail out if the next token isn't one we expect. - if (!Tok.is(tok::colon) && !Tok.is(tok::l_brace)) + if (!Tok.is(tok::colon) && !Tok.is(tok::l_brace)) { + if (TagDecl) + Actions.ActOnTagDefinitionError(getCurScope(), TagDecl); return; + } } if (Tok.is(tok::colon)) { diff --git a/clang/test/Parser/cxx0x-attributes.cpp b/clang/test/Parser/cxx0x-attributes.cpp index 02791f4f54c..9dbefb0f483 100644 --- a/clang/test/Parser/cxx0x-attributes.cpp +++ b/clang/test/Parser/cxx0x-attributes.cpp @@ -86,6 +86,10 @@ class [[]] [[]] final_class_another [[]] [[]] alignas(16) final // expected-error {{an attribute list cannot appear here}} [[]] [[]] alignas(16) [[]]{}; // expected-error {{an attribute list cannot appear here}} +// The diagnostics here don't matter much, this just shouldn't crash: +class C final [[deprecated(l]] {}); // expected-error {{use of undeclared identifier}} expected-error {{expected ']'}} expected-error {{an attribute list cannot appear here}} expected-error {{expected unqualified-id}} +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}} template<typename> [[]] struct no_init_declarators_template; // expected-error {{an attribute list cannot appear here}} @@ -330,7 +334,3 @@ namespace { [[deprecated()]] void foo(); // expected-error {{parentheses must be omitted if 'deprecated' attribute's argument list is empty}} [[gnu::deprecated()]] void quux(); } - -// The diagnostics here don't matter much, this just shouldn't crash: -class C final [[deprecated(l]] {}; // expected-error {{use of undeclared identifier}} expected-error {{expected ']'}} expected-error {{an attribute list cannot appear here}} -class C final alignas ([l) {}; // expected-error {{expected ';' after class}} |