diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-09-13 19:12:50 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-09-13 19:12:50 +0000 |
commit | 3686c71ff92e4357a78993a16a27185f16ab6234 (patch) | |
tree | 086c57b4ae35b39dff648f3895b2440c5bdbd998 | |
parent | a406849092567a448b6cef37df83df3c2b36f3ca (diff) |
Recover properly after a parse error in a static_assert declaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163826 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 7 | ||||
-rw-r--r-- | test/Parser/cxx0x-decl.cpp | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 3bce8a87be..64a3ef0deb 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -616,12 +616,13 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){ BalancedDelimiterTracker T(*this, tok::l_paren); if (T.consumeOpen()) { Diag(Tok, diag::err_expected_lparen); + SkipMalformedDecl(); return 0; } ExprResult AssertExpr(ParseConstantExpression()); if (AssertExpr.isInvalid()) { - SkipUntil(tok::semi); + SkipMalformedDecl(); return 0; } @@ -630,13 +631,13 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){ if (!isTokenStringLiteral()) { Diag(Tok, diag::err_expected_string_literal); - SkipUntil(tok::semi); + SkipMalformedDecl(); return 0; } ExprResult AssertMessage(ParseStringLiteralExpression()); if (AssertMessage.isInvalid()) { - SkipUntil(tok::semi); + SkipMalformedDecl(); return 0; } diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp index e97ba1ec90..13c7fbf0b0 100644 --- a/test/Parser/cxx0x-decl.cpp +++ b/test/Parser/cxx0x-decl.cpp @@ -30,3 +30,5 @@ class ExtraSemiAfterMemFn { // pedantically warn on it int *const const p = 0; // expected-warning {{duplicate 'const' declaration specifier}} const const int *q = 0; // expected-warning {{duplicate 'const' declaration specifier}} + +static_assert(something, ""); // expected-error {{undeclared identifier}} |