Commit 3c8d1256 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Recognize C++0x sizeof... expressions.

parent ddcc40d0
...@@ -1632,8 +1632,18 @@ unsigned SizeofExpressionAST::firstToken() const ...@@ -1632,8 +1632,18 @@ unsigned SizeofExpressionAST::firstToken() const
unsigned SizeofExpressionAST::lastToken() const unsigned SizeofExpressionAST::lastToken() const
{ {
if (expression) if (rparen_token)
return rparen_token + 1;
else if (expression)
return expression->lastToken(); return expression->lastToken();
else if (lparen_token)
return lparen_token + 1;
else if (dot_dot_dot_token)
return dot_dot_dot_token + 1;
return sizeof_token + 1; return sizeof_token + 1;
} }
......
...@@ -2887,6 +2887,7 @@ class CPLUSPLUS_EXPORT SizeofExpressionAST: public ExpressionAST ...@@ -2887,6 +2887,7 @@ class CPLUSPLUS_EXPORT SizeofExpressionAST: public ExpressionAST
{ {
public: public:
unsigned sizeof_token; unsigned sizeof_token;
unsigned dot_dot_dot_token;
unsigned lparen_token; unsigned lparen_token;
ExpressionAST *expression; ExpressionAST *expression;
unsigned rparen_token; unsigned rparen_token;
......
...@@ -4268,6 +4268,11 @@ bool Parser::parseUnaryExpression(ExpressionAST *&node) ...@@ -4268,6 +4268,11 @@ bool Parser::parseUnaryExpression(ExpressionAST *&node)
SizeofExpressionAST *ast = new (_pool) SizeofExpressionAST; SizeofExpressionAST *ast = new (_pool) SizeofExpressionAST;
ast->sizeof_token = consumeToken(); ast->sizeof_token = consumeToken();
// sizeof...(Args)
if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT && (LA(2) == T_IDENTIFIER || (LA(2) == T_LPAREN && LA(3) == T_IDENTIFIER
&& LA(4) == T_RPAREN)))
ast->dot_dot_dot_token = consumeToken();
if (LA() == T_LPAREN) { if (LA() == T_LPAREN) {
unsigned lparen_token = consumeToken(); unsigned lparen_token = consumeToken();
if (parseTypeId(ast->expression) && LA() == T_RPAREN) { if (parseTypeId(ast->expression) && LA() == T_RPAREN) {
......
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