diff --git a/src/libs/3rdparty/cplusplus/Keywords.cpp b/src/libs/3rdparty/cplusplus/Keywords.cpp index 2062e40c7b8..3d1b50e67a2 100644 --- a/src/libs/3rdparty/cplusplus/Keywords.cpp +++ b/src/libs/3rdparty/cplusplus/Keywords.cpp @@ -136,6 +136,13 @@ static inline int classify4(const char *s, bool q, bool) { } } } + else if (q && s[1] == 'm') { + if (s[2] == 'i') { + if (s[3] == 't') { + return T_EMIT; + } + } + } } else if (s[0] == 'g') { if (s[1] == 'o') { @@ -417,6 +424,19 @@ static inline int classify6(const char *s, bool q, bool) { } } } + else if (q && s[0] == 'Q') { + if (s[1] == '_') { + if (s[2] == 'E') { + if (s[3] == 'M') { + if (s[4] == 'I') { + if (s[5] == 'T') { + return T_Q_EMIT; + } + } + } + } + } + } else if (s[0] == 'r') { if (s[1] == 'e') { if (s[2] == 't') { diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index 2b57278b060..1011297f415 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -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); diff --git a/src/libs/3rdparty/cplusplus/Token.cpp b/src/libs/3rdparty/cplusplus/Token.cpp index 5183de593a0..90210024833 100644 --- a/src/libs/3rdparty/cplusplus/Token.cpp +++ b/src/libs/3rdparty/cplusplus/Token.cpp @@ -71,10 +71,10 @@ static const char *token_names[] = { ("@synchronized"), ("@synthesize"), ("@throw"), ("@try"), // Qt keywords - ("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"), + ("emit"), ("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"), ("Q_FOREACH"), ("Q_D"), ("Q_Q"), ("Q_INVOKABLE"), ("Q_PROPERTY"), ("T_Q_PRIVATE_PROPERTY"), - ("Q_INTERFACES"), ("Q_ENUMS"), ("Q_FLAGS"), + ("Q_INTERFACES"), ("Q_EMIT"), ("Q_ENUMS"), ("Q_FLAGS"), ("Q_PRIVATE_SLOT"), ("Q_DECLARE_INTERFACE"), ("Q_OBJECT"), ("Q_GADGET"), }; diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h index a30474adc67..41abe17e9ab 100644 --- a/src/libs/3rdparty/cplusplus/Token.h +++ b/src/libs/3rdparty/cplusplus/Token.h @@ -217,7 +217,8 @@ enum Kind { T_FIRST_QT_KEYWORD, // Qt keywords - T_SIGNAL = T_FIRST_QT_KEYWORD, + T_EMIT = T_FIRST_QT_KEYWORD, + T_SIGNAL, T_SLOT, T_Q_SIGNAL, T_Q_SLOT, @@ -230,6 +231,7 @@ enum Kind { T_Q_PROPERTY, T_Q_PRIVATE_PROPERTY, T_Q_INTERFACES, + T_Q_EMIT, T_Q_ENUMS, T_Q_FLAGS, T_Q_PRIVATE_SLOT, diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index ea8c75e0198..7702aadd0a9 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -1813,6 +1813,10 @@ bool Preprocessor::isQtReservedWord(const ByteArrayRef ¯oId) return true; else if (size == 5 && macroId.at(0) == 's' && macroId == "slots") return true; + else if (size == 4 && macroId.at(0) == 'e' && macroId == "emit") + return true; + else if (size == 6 && macroId.at(0) == 'Q' && macroId == "Q_EMIT") + return true; return false; }