Commit 89ac110a authored by Leandro Melo's avatar Leandro Melo Committed by Leandro T. C. Melo
Browse files

C++: Relax parsing for templateid in some cases

The correct parsing for certain templateids would require name
lookup. In order to avoid erroneous syntax errors detection (like
the one below ) we block the notification for such cases.

bool r = a < b ? c > d : false;

Task-number: QTCREATORBUG-5122
Change-Id: I9eb9ee89cd21bec3ed924982957f50f9346f90be
Reviewed-on: http://codereview.qt.nokia.com/1704

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent f87137a7
......@@ -380,8 +380,14 @@ bool Parser::parseClassOrNamespaceName(NameAST *&node)
if (LA() == T_IDENTIFIER && (LA(2) == T_COLON_COLON || LA(2) == T_LESS)) {
unsigned identifier_token = cursor();
if (LA(2) == T_LESS && parseTemplateId(node) && LA() == T_COLON_COLON)
return true;
if (LA(2) == T_LESS) {
bool blocked = blockErrors(true);
if (parseTemplateId(node) && LA() == T_COLON_COLON) {
blockErrors(blocked);
return true;
}
blockErrors(blocked);
}
rewind(identifier_token);
......@@ -2695,19 +2701,24 @@ bool Parser::parseUnqualifiedName(NameAST *&node, bool acceptTemplateId)
rewind(operator_token);
return parseConversionFunctionId(node);
} else if (LA() == T_IDENTIFIER) {
unsigned identifier_token = cursor();
if (acceptTemplateId && LA(2) == T_LESS && parseTemplateId(node)) {
if (! _templateArguments || (LA() == T_COMMA || LA() == T_GREATER ||
LA() == T_LPAREN || LA() == T_RPAREN ||
LA() == T_STAR || LA() == T_AMPER || // ptr-operators
LA() == T_COLON_COLON))
return true;
}
rewind(identifier_token);
SimpleNameAST *ast = new (_pool) SimpleNameAST;
ast->identifier_token = consumeToken();
node = ast;
return true;
unsigned identifier_token = cursor();
if (acceptTemplateId && LA(2) == T_LESS) {
bool blocked = blockErrors(true);
if (parseTemplateId(node)
&& (! _templateArguments || (LA() == T_COMMA || LA() == T_GREATER ||
LA() == T_LPAREN || LA() == T_RPAREN ||
LA() == T_STAR || LA() == T_AMPER || // ptr-operators
LA() == T_COLON_COLON))) {
blockErrors(blocked);
return true;
}
blockErrors(blocked);
}
rewind(identifier_token);
SimpleNameAST *ast = new (_pool) SimpleNameAST;
ast->identifier_token = consumeToken();
node = ast;
return true;
} else if (LA() == T_TEMPLATE) {
unsigned template_token = consumeToken();
if (parseTemplateId(node, template_token))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment