@@ -1073,13 +1073,16 @@ class cppfront
1073
1073
struct function_return {
1074
1074
parameter_declaration_list_node* param_list;
1075
1075
passing_style pass;
1076
+ bool is_deduced;
1076
1077
1077
1078
function_return (
1078
1079
parameter_declaration_list_node* param_list_,
1079
- passing_style pass_ = passing_style::invalid
1080
+ passing_style pass_ = passing_style::invalid,
1081
+ bool is_deduced_ = false
1080
1082
)
1081
1083
: param_list{param_list_}
1082
1084
, pass{pass_}
1085
+ , is_deduced{is_deduced_}
1083
1086
{ }
1084
1087
};
1085
1088
std::vector<function_return> function_returns;
@@ -2217,12 +2220,17 @@ class cppfront
2217
2220
if (n.expression )
2218
2221
{
2219
2222
assert (!current_functions.empty ());
2220
-
2221
- // If we're doing a forward return
2223
+ auto is_forward_return =
2224
+ !function_returns.empty ()
2225
+ && function_returns.back ().pass == passing_style::forward;
2226
+ auto is_deduced_return =
2227
+ !function_returns.empty ()
2228
+ && function_returns.back ().is_deduced ;
2229
+
2230
+ // If we're doing a forward return of a single-token name
2222
2231
if (auto tok = n.expression ->expr ->get_postfix_expression_node ()->expr ->get_token ();
2223
2232
tok
2224
- && !function_returns.empty ()
2225
- && function_returns.back ().pass == passing_style::forward
2233
+ && is_forward_return
2226
2234
)
2227
2235
{
2228
2236
// Ensure we're not returning a local or an in/move parameter
@@ -2267,9 +2275,13 @@ class cppfront
2267
2275
// take over direct control of emitting it without needing to
2268
2276
// go through the whole grammar, and surround it with braces
2269
2277
if (n.expression ->is_expression_list ()) {
2270
- printer.print_cpp2 ( " { " , n.position () );
2278
+ if (!is_deduced_return) {
2279
+ printer.print_cpp2 ( " { " , n.position () );
2280
+ }
2271
2281
emit (*n.expression ->get_expression_list (), false );
2272
- printer.print_cpp2 ( " }" , n.position () );
2282
+ if (!is_deduced_return) {
2283
+ printer.print_cpp2 ( " }" , n.position () );
2284
+ }
2273
2285
}
2274
2286
// Otherwise, just emit the general expression as usual
2275
2287
else {
@@ -3670,9 +3682,17 @@ class cppfront
3670
3682
&& n.expr ->is_expression_list ()
3671
3683
)
3672
3684
{
3673
- printer.print_cpp2 ( " { " , n.position () );
3685
+ auto is_deduced_return =
3686
+ !function_returns.empty ()
3687
+ && function_returns.back ().is_deduced ;
3688
+
3689
+ if (!is_deduced_return) {
3690
+ printer.print_cpp2 ( " { " , n.position () );
3691
+ }
3674
3692
emit (*n.expr ->get_expression_list (), false );
3675
- printer.print_cpp2 ( " }" , n.position () );
3693
+ if (!is_deduced_return) {
3694
+ printer.print_cpp2 ( " }" , n.position () );
3695
+ }
3676
3696
}
3677
3697
// Otherwise, just emit the general expression as usual
3678
3698
else {
@@ -5634,7 +5654,8 @@ class cppfront
5634
5654
else if (func->returns .index () == function_type_node::id) {
5635
5655
function_returns.emplace_back (
5636
5656
&single_anon, // use special value as a note
5637
- std::get<function_type_node::id>(func->returns ).pass
5657
+ std::get<function_type_node::id>(func->returns ).pass ,
5658
+ std::get<function_type_node::id>(func->returns ).type ->is_wildcard ()
5638
5659
);
5639
5660
}
5640
5661
else {
0 commit comments