forked from qt-creator/qt-creator
C++: Parse emit/Q_EMIT properly
The parser now understands emit/Q_EMIT as an expression statement. Also, the recent fixes in the preprocessor introduced a side-effect in the hanlding of code such as: emit signal(); Member signal started being treated as a local use (parsed as a declaration) and possibily being highlighted as unused variable. Previously that worked by accident since there was an inconsistency in the preprocessor on which only object-like macros were being expanded even when the "no expand" flag was set. Then, the code mentioned above was being parsed as an expression, what kind of worked. Change-Id: I47a68ed4c1c1702872620b8ed7c7264fb0997034 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
17
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
17
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -2947,6 +2947,23 @@ bool Parser::parseStatement(StatementAST *&node)
|
||||
node = ast;
|
||||
} return true;
|
||||
|
||||
case T_EMIT:
|
||||
case T_Q_EMIT: {
|
||||
// Simply skip the emit token and parse as an expression statement - no strong
|
||||
// reason to have an specific ast type.
|
||||
consumeToken();
|
||||
ExpressionAST *expression = 0;
|
||||
if (parsePostfixExpression(expression)) {
|
||||
ExpressionStatementAST *ast = new (_pool) ExpressionStatementAST;
|
||||
ast->expression = expression;
|
||||
match(T_SEMICOLON, &ast->semicolon_token);
|
||||
node = ast;
|
||||
return true;
|
||||
}
|
||||
error(cursor(), "expected statement");
|
||||
return false;
|
||||
}
|
||||
|
||||
default:
|
||||
if (LA() == T_IDENTIFIER && LA(2) == T_COLON)
|
||||
return parseLabeledStatement(node);
|
||||
|
||||
Reference in New Issue
Block a user