]> granicus.if.org Git - clang/commitdiff
Recover properly after a parse error in a static_assert declaration.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 13 Sep 2012 19:12:50 +0000 (19:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 13 Sep 2012 19:12:50 +0000 (19:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163826 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDeclCXX.cpp
test/Parser/cxx0x-decl.cpp

index 3bce8a87be2f76beccabbda107ce146920694597..64a3ef0debf3f47deb3cb03b9e56fb8abf897e69 100644 (file)
@@ -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;
   }
 
index e97ba1ec90380a808018188948d71a73c5266e37..13c7fbf0b01371f332cfb2639f8e0e07eb28dd54 100644 (file)
@@ -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}}