Commit 8b625a86 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Parse C++0x mem-initializer-list.

parent 199d1e14
......@@ -694,7 +694,9 @@ unsigned CtorInitializerAST::firstToken() const
unsigned CtorInitializerAST::lastToken() const
{
if (member_initializer_list)
if (dot_dot_dot_token)
return dot_dot_dot_token + 1;
else if (member_initializer_list)
return member_initializer_list->lastToken();
return colon_token + 1;
}
......
......@@ -1314,11 +1314,13 @@ class CPLUSPLUS_EXPORT CtorInitializerAST: public AST
public:
unsigned colon_token;
MemInitializerListAST *member_initializer_list;
unsigned dot_dot_dot_token;
public:
CtorInitializerAST()
: colon_token(0)
, member_initializer_list(0)
, dot_dot_dot_token(0)
{}
virtual CtorInitializerAST *asCtorInitializer() { return this; }
......
......@@ -2087,6 +2087,10 @@ bool Parser::parseCtorInitializer(CtorInitializerAST *&node)
ast->colon_token = colon_token;
parseMemInitializerList(ast->member_initializer_list);
if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
ast->dot_dot_dot_token = consumeToken();
node = ast;
return true;
}
......@@ -2243,6 +2247,9 @@ bool Parser::parseMemInitializerList(MemInitializerListAST *&node)
if (LA() == T_LBRACE)
break;
else if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT && LA(2) == T_LBRACE)
break;
else if (LA() == T_COMMA || (LA() == T_IDENTIFIER && (LA(2) == T_LPAREN || LA(2) == T_COLON_COLON))) {
if (LA() != T_COMMA)
_translationUnit->error(cursor(), "expected `,'");
......@@ -2257,8 +2264,13 @@ bool Parser::parseMemInitializerList(MemInitializerListAST *&node)
} else break;
}
if (LA() != T_LBRACE)
if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT) {
if (LA(2) != T_LBRACE)
_translationUnit->error(cursor(), "expected `{'");
} else if (LA() != T_LBRACE) {
_translationUnit->error(cursor(), "expected `{'");
}
return true;
}
......
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