C++: Fix return type of lambda

Relying on "_type" for the lambda was wrong.

In case of the bug report the return type of the lambda happened to be
the template class. Because of that Clone never stopped cloning.

Change-Id: I377d12e6a8278198abd1488fbdbc89b4157c1357
Task-number: QTCREATORBUG-12631
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-07-10 11:24:45 +02:00
parent 65461ab033
commit 33a80e56cc
2 changed files with 115 additions and 10 deletions

View File

@@ -1095,20 +1095,24 @@ Function *Bind::lambdaDeclarator(LambdaDeclaratorAST *ast)
Function *fun = control()->newFunction(0, 0);
fun->setStartOffset(tokenAt(ast->firstToken()).utf16charsBegin());
fun->setEndOffset(tokenAt(ast->lastToken() - 1).utf16charsEnd());
FullySpecifiedType type;
if (ast->trailing_return_type)
_type = this->trailingReturnType(ast->trailing_return_type, _type);
fun->setReturnType(_type);
type = this->trailingReturnType(ast->trailing_return_type, type);
ast->symbol = fun;
// unsigned lparen_token = ast->lparen_token;
FullySpecifiedType type;
this->parameterDeclarationClause(ast->parameter_declaration_clause, ast->lparen_token, fun);
// unsigned rparen_token = ast->rparen_token;
for (SpecifierListAST *it = ast->attributes; it; it = it->next) {
type = this->specifier(it->value, type);
}
// unsigned mutable_token = ast->mutable_token;
_type = this->exceptionSpecification(ast->exception_specification, type);
type = this->exceptionSpecification(ast->exception_specification, type);
if (!type.isValid())
type.setType(control()->voidType());
fun->setReturnType(type);
return fun;
}