Commit 30c59e27 authored by Christian Kamm's avatar Christian Kamm Committed by hjk

C++11: Fix parsing of ambiguous declarators.

Task-number: QTCREATORBUG-7921

Change-Id: Ia94c30886321e09028547a47f83d2a0c57f3980f
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent c1755d4d
......@@ -1461,6 +1461,7 @@ public:
unsigned ref_qualifier_token;
ExceptionSpecificationAST *exception_specification;
TrailingReturnTypeAST *trailing_return_type;
// Some FunctionDeclarators can also be interpreted as an initializer, like for 'A b(c);'
ExpressionAST *as_cpp_initializer;
public: // annotations
......
......@@ -1491,11 +1491,12 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specif
bool blocked = blockErrors(true);
if (parseInitializer(initializer, &node->equal_token)) {
NestedExpressionAST *expr = 0;
// maybe the initializer also parses as a FunctionDeclarator?
ExpressionListParenAST *expr = 0;
if (initializer)
expr = initializer->asNestedExpression();
expr = initializer->asExpressionListParen();
if (expr) {
if (expr->expression && expr->rparen_token && (LA() == T_COMMA || LA() == T_SEMICOLON)) {
if (expr->expression_list && expr->rparen_token && (LA() == T_COMMA || LA() == T_SEMICOLON)) {
rewind(lparen_token);
// check for ambiguous declarators.
......
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