forked from qt-creator/qt-creator
CPlusPlus: Add missing error check to parseExpressionStatement()
Fixes: QTCREATORBUG-32043 Change-Id: Ic4f1716339d1277d0a2d5a237fd6ae0389ed2485 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
16
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
16
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -487,15 +487,17 @@ int Parser::find(int token, int stopAt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Parser::match(int kind, int *token)
|
||||
bool Parser::match(int kind, int *token)
|
||||
{
|
||||
if (LA() == kind)
|
||||
if (LA() == kind) {
|
||||
*token = consumeToken();
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
||||
*token = 0;
|
||||
error(_tokenIndex, "expected token `%s' got `%s'",
|
||||
Token::name(kind), tok().spell());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Parser::parseClassOrNamespaceName(NameAST *&node)
|
||||
@@ -3503,7 +3505,8 @@ bool Parser::parseExpressionStatement(StatementAST *&node)
|
||||
DEBUG_THIS_RULE();
|
||||
if (LA() == T_SEMICOLON) {
|
||||
ExpressionStatementAST *ast = new (_pool) ExpressionStatementAST;
|
||||
match(T_SEMICOLON, &ast->semicolon_token);
|
||||
if (!match(T_SEMICOLON, &ast->semicolon_token))
|
||||
return false;
|
||||
node = ast;
|
||||
return true;
|
||||
}
|
||||
@@ -3524,10 +3527,11 @@ bool Parser::parseExpressionStatement(StatementAST *&node)
|
||||
ExpressionStatementAST *ast = new (previousPool) ExpressionStatementAST;
|
||||
if (expression)
|
||||
ast->expression = expression->clone(previousPool);
|
||||
match(T_SEMICOLON, &ast->semicolon_token);
|
||||
if (match(T_SEMICOLON, &ast->semicolon_token)) {
|
||||
node = ast;
|
||||
parsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
_inExpressionStatement = wasInExpressionStatement;
|
||||
|
||||
|
2
src/libs/3rdparty/cplusplus/Parser.h
vendored
2
src/libs/3rdparty/cplusplus/Parser.h
vendored
@@ -273,7 +273,7 @@ public:
|
||||
const Identifier *className(ClassSpecifierAST *ast) const;
|
||||
const Identifier *identifier(NameAST *name) const;
|
||||
|
||||
void match(int kind, int *token);
|
||||
bool match(int kind, int *token);
|
||||
|
||||
bool maybeAmbiguousStatement(DeclarationStatementAST *ast, StatementAST *&node);
|
||||
bool maybeForwardOrClassDeclaration(SpecifierListAST *decl_specifier_seq) const;
|
||||
|
Reference in New Issue
Block a user