C++11: Allow for brace initializers like T v{1, 2}.

And add a basic test.

Change-Id: I3b8b87d51a9da154758d17380bba5922795f675c
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Christian Kamm
2012-09-12 12:10:37 +02:00
committed by hjk
parent e5699c0925
commit 813846232b
5 changed files with 28 additions and 55 deletions

View File

@@ -2493,6 +2493,10 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
consumeToken();
}
const bool isFunctionDeclarator = node
&& node->postfix_declarator_list
&& node->postfix_declarator_list->lastValue()
&& node->postfix_declarator_list->lastValue()->asFunctionDeclarator();
if (declaringClass && LA() == T_COLON
&& (! node || ! node->postfix_declarator_list)) {
unsigned colon_token = consumeToken();
@@ -2506,7 +2510,7 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
return true;
}
rewind(colon_token);
} else if (node->core_declarator && (LA() == T_EQUAL || (! declaringClass && LA() == T_LPAREN))) {
} else if (node->core_declarator && (LA() == T_EQUAL || (_cxx0xEnabled && !isFunctionDeclarator && LA() == T_LBRACE) || (! declaringClass && LA() == T_LPAREN))) {
parseInitializer(node->initializer, &node->equal_token);
}
return true;