Skip to content

Commit

Permalink
Fix bug when emitting duplicate {} for temporary object initializations
Browse files Browse the repository at this point in the history
  • Loading branch information
hsutter committed Aug 31, 2024
1 parent 1c603ca commit a18d22e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions source/to_cpp1.h
Original file line number Diff line number Diff line change
Expand Up @@ -4064,11 +4064,6 @@ class cppfront
)
-> void
{ STACKINSTR
if (n.default_initializer) {
printer.print_cpp2("{}", n.position());
return;
}

auto add_parens =
should_add_expression_list_parens()
&& !n.inside_initializer
Expand All @@ -4078,6 +4073,14 @@ class cppfront
n.is_fold_expression() &&
!(n.inside_initializer && current_declarations.back()->initializer->position() != n.open_paren->position())
;

if (n.default_initializer) {
if (add_parens) {
printer.print_cpp2("{}", n.position());
}
return;
}

if (add_parens) {
printer.print_cpp2( *n.open_paren, n.position());
}
Expand Down

0 comments on commit a18d22e

Please sign in to comment.