Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions src/parser/cxx/ast_rewriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2516,17 +2516,27 @@ auto ASTRewriter::ExpressionVisitor::operator()(LambdaExpressionAST* ast)
lambdaSpecifierList = &(*lambdaSpecifierList)->next;
}

copy->exceptionSpecifier = rewrite(ast->exceptionSpecifier);
{
auto _ = Binder::ScopeGuard(binder());

for (auto attributeList = &copy->attributeList;
auto node : ListView{ast->attributeList}) {
auto value = rewrite(node);
*attributeList = make_list_node(arena(), value);
attributeList = &(*attributeList)->next;
if (copy->parameterDeclarationClause) {
binder()->setScope(
copy->parameterDeclarationClause->functionParametersSymbol);
}

copy->exceptionSpecifier = rewrite(ast->exceptionSpecifier);

for (auto attributeList = &copy->attributeList;
auto node : ListView{ast->attributeList}) {
auto value = rewrite(node);
*attributeList = make_list_node(arena(), value);
attributeList = &(*attributeList)->next;
}

copy->trailingReturnType = rewrite(ast->trailingReturnType);
copy->requiresClause = rewrite(ast->requiresClause);
}

copy->trailingReturnType = rewrite(ast->trailingReturnType);
copy->requiresClause = rewrite(ast->requiresClause);
copy->statement = ast_cast<CompoundStatementAST>(rewrite(ast->statement));
copy->captureDefault = ast->captureDefault;
copy->symbol = ast->symbol;
Expand Down Expand Up @@ -3974,6 +3984,13 @@ auto ASTRewriter::DeclaratorChunkVisitor::operator()(
copy->parameterDeclarationClause = rewrite(ast->parameterDeclarationClause);
copy->rparenLoc = ast->rparenLoc;

auto _ = Binder::ScopeGuard{binder()};

if (copy->parameterDeclarationClause) {
binder()->setScope(
copy->parameterDeclarationClause->functionParametersSymbol);
}

auto cvQualifierListCtx = DeclSpecs{rewriter()};
for (auto cvQualifierList = &copy->cvQualifierList;
auto node : ListView{ast->cvQualifierList}) {
Expand Down
4 changes: 4 additions & 0 deletions src/parser/cxx/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,8 @@ auto Parser::parse_lambda_expression(ExpressionAST*& yyast) -> bool {
}

expect(TokenKind::T_RPAREN, ast->rparenLoc);

setScope(ast->parameterDeclarationClause->functionParametersSymbol);
}

parse_optional_attribute_specifier_seq(ast->gnuAtributeList,
Expand Down Expand Up @@ -5452,6 +5454,8 @@ auto Parser::parse_function_declarator(FunctionDeclaratorChunkAST*& yyast,
}

if (!match(TokenKind::T_RPAREN, rparenLoc)) return false;

setScope(parameterDeclarationClause->functionParametersSymbol);
}

lookahead.commit();
Expand Down
11 changes: 11 additions & 0 deletions tests/unit_tests/sema/trailing_return_type_02.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %cxx -verify -fcheck -dump-symbols %s | %filecheck %s

auto f(int x) -> decltype(x);
auto g(int x, decltype(x)* y) -> decltype(y);
auto k(int x) -> decltype((x));

// clang-format off
// CHECK:namespace
// CHECK-NEXT: function int f(int)
// CHECK-NEXT: function int* g(int, int*)
// CHECK-NEXT: function int& k(int)