Fix invalid decltype error recovery which resulted in crashes.

Task-number: QTCREATORBUG-7174

Change-Id: I653db71adc45586cd8518ffd96118425fd3763be
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Erik Verbruggen
2012-03-28 13:34:31 +02:00
parent 0f21515277
commit 275e207d26
2 changed files with 10 additions and 4 deletions

View File

@@ -3638,11 +3638,9 @@ bool Parser::parseBuiltinTypeSpecifier(SpecifierListAST *&node)
DecltypeSpecifierAST *ast = new (_pool) DecltypeSpecifierAST;
ast->decltype_token = consumeToken();
match(T_LPAREN, &ast->lparen_token);
if (parseExpression(ast->expression)) {
if (parseExpression(ast->expression))
match(T_RPAREN, &ast->rparen_token);
node = new (_pool) SpecifierListAST(ast);
return true;
}
node = new (_pool) SpecifierListAST(ast);
skipUntilDeclaration();
return true;
} else if (lookAtBuiltinTypeSpecifier()) {

View File

@@ -101,6 +101,7 @@ private slots:
void gcc_attributes_1();
void gcc_attributes_2();
void gcc_attributes_3();
void crash_test_1();
// expressions
void simple_name_1();
@@ -212,6 +213,13 @@ void tst_AST::gcc_attributes_3()
QCOMPARE(unit->tokenKind(link->rbrace_token), (int) T_RBRACE);
}
void tst_AST::crash_test_1()
{
QSharedPointer<TranslationUnit> unit(parseStatement("decltype auto\n"));
AST *ast = unit->ast();
QVERIFY(ast);
}
void tst_AST::simple_declaration_1()
{
QSharedPointer<TranslationUnit> unit(parseStatement("\n"