forked from qt-creator/qt-creator
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: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
committed by
Leandro T. C. Melo
parent
f87137a703
commit
89ac110ab0
41
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
41
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user