Commit ddcc40d0 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Accepts `...' when parsing declarator-ids in C++0x.

parent a52b8266
......@@ -760,12 +760,22 @@ unsigned DeclarationStatementAST::lastToken() const
unsigned DeclaratorIdAST::firstToken() const
{
if (dot_dot_dot_token)
return dot_dot_dot_token;
return name->firstToken();
}
unsigned DeclaratorIdAST::lastToken() const
{
return name->lastToken();
if (name)
return name->lastToken();
else if (dot_dot_dot_token)
return dot_dot_dot_token + 1;
// assert?
return 0;
}
unsigned DeleteExpressionAST::firstToken() const
......
......@@ -1368,11 +1368,13 @@ protected:
class CPLUSPLUS_EXPORT DeclaratorIdAST: public CoreDeclaratorAST
{
public:
unsigned dot_dot_dot_token;
NameAST *name;
public:
DeclaratorIdAST()
: name(0)
: dot_dot_dot_token(0)
, name(0)
{}
virtual DeclaratorIdAST *asDeclaratorId() { return this; }
......
......@@ -447,6 +447,7 @@ DeclarationStatementAST *DeclarationStatementAST::clone(MemoryPool *pool) const
DeclaratorIdAST *DeclaratorIdAST::clone(MemoryPool *pool) const
{
DeclaratorIdAST *ast = new (pool) DeclaratorIdAST;
ast->dot_dot_dot_token = dot_dot_dot_token;
if (name)
ast->name = name->clone(pool);
return ast;
......
......@@ -731,6 +731,8 @@ bool ASTMatcher::match(DeclaratorIdAST *node, DeclaratorIdAST *pattern)
(void) node;
(void) pattern;
pattern->dot_dot_dot_token = node->dot_dot_dot_token;
if (! pattern->name)
pattern->name = node->name;
else if (! AST::match(node->name, pattern->name, this))
......
......@@ -1218,11 +1218,18 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node)
while (parsePtrOperator(*ptr_operators_tail))
ptr_operators_tail = &(*ptr_operators_tail)->next;
if (LA() == T_COLON_COLON || LA() == T_IDENTIFIER || LA() == T_TILDE
|| LA() == T_OPERATOR) {
if (LA() == T_COLON_COLON || LA() == T_IDENTIFIER || LA() == T_TILDE || LA() == T_OPERATOR
|| (_cxx0xEnabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_COLON_COLON || LA(2) == T_IDENTIFIER))) {
unsigned dot_dot_dot_token = 0;
if (LA() == T_DOT_DOT_DOT)
dot_dot_dot_token = consumeToken();
NameAST *name = 0;
if (parseName(name)) {
DeclaratorIdAST *declarator_id = new (_pool) DeclaratorIdAST;
declarator_id->dot_dot_dot_token = dot_dot_dot_token;
declarator_id->name = name;
DeclaratorAST *ast = new (_pool) DeclaratorAST;
ast->attribute_list = attributes;
......
Supports Markdown
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