Skip to content

Commit ba63bc5

Browse files
committed
Allow simple subobject default init syntax
1 parent ebdcd85 commit ba63bc5

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

source/cppfront.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,8 +2045,14 @@ class cppfront
20452045
//
20462046
auto emit(expression_list_node const& n) -> void
20472047
{
2048-
if (should_add_expression_list_parens() && !n.expressions.empty() && !n.inside_initializer) {
2049-
printer.print_cpp2("(", n.position());
2048+
auto add_parens = should_add_expression_list_parens() && !n.inside_initializer;
2049+
if (add_parens) {
2050+
if (n.expressions.empty()) {
2051+
printer.print_cpp2( "{", n.position());
2052+
}
2053+
else {
2054+
printer.print_cpp2( "(", n.position());
2055+
}
20502056
}
20512057

20522058
auto first = true;
@@ -2089,8 +2095,13 @@ class cppfront
20892095
}
20902096
}
20912097

2092-
if (should_add_expression_list_parens() && !n.expressions.empty() && !n.inside_initializer) {
2093-
printer.print_cpp2(")", n.position());
2098+
if (add_parens) {
2099+
if (n.expressions.empty()) {
2100+
printer.print_cpp2( "}", n.position());
2101+
}
2102+
else {
2103+
printer.print_cpp2( ")", n.position());
2104+
}
20942105
}
20952106
// We want to consume only one of these
20962107
consumed_expression_list_parens();

0 commit comments

Comments
 (0)