From 5a1924f1a06e31105b5f7823cb6a5f5f20513f49 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 15 Sep 2010 16:43:04 +0200 Subject: C++: fixed invalid parsing of 'call()->call()'. --- src/shared/cplusplus/Parser.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/shared/cplusplus') diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 73cea0009b..eb1b7f7463 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -1392,8 +1392,21 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specif // ### parse ref-qualifiers parseExceptionSpecification(ast->exception_specification); - if (_cxx0xEnabled && ! node->ptr_operator_list && LA() == T_ARROW) - parseTrailingReturnType(ast->trailing_return_type); + if (_cxx0xEnabled && ! node->ptr_operator_list && LA() == T_ARROW) { + // only allow if there is 1 type spec, which has to be 'auto' + bool hasAuto = false; + for (SpecifierListAST *iter = decl_specifier_list; !hasAuto && iter; iter = iter->next) { + SpecifierAST *spec = iter->value; + if (SimpleSpecifierAST *simpleSpec = spec->asSimpleSpecifier()) { + if (_translationUnit->tokenKind(simpleSpec->specifier_token) == T_AUTO) { + hasAuto = true; + } + } + } + + if (hasAuto) + parseTrailingReturnType(ast->trailing_return_type); + } *postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast); postfix_ptr = &(*postfix_ptr)->next; -- cgit v1.2.1