@@ -1255,7 +1255,7 @@ class cppfront
1255
1255
1256
1256
// Now we'll open the Cpp1 file
1257
1257
auto cpp1_filename = sourcefile.substr (0 , std::ssize (sourcefile) - 1 );
1258
-
1258
+
1259
1259
// Use explicit filename override if present,
1260
1260
// otherwise strip leading path
1261
1261
if (!flag_cpp1_filename.empty ()) {
@@ -3428,12 +3428,12 @@ class cppfront
3428
3428
last_was_prefixed = true ;
3429
3429
}
3430
3430
3431
- // Handle the other Cpp2 postfix operators that stay postfix in Cpp1
3431
+ // Handle the other Cpp2 postfix operators that stay postfix in Cpp1
3432
3432
// (currently '...' for expansion, not when used as a range operator)
3433
3433
else if (
3434
3434
is_postfix_operator (i->op ->type ())
3435
3435
&& !i->last_expr // not being used as a range operator
3436
- )
3436
+ )
3437
3437
{
3438
3438
flush_args ();
3439
3439
suffix.emplace_back ( i->op ->to_string (), i->op ->position ());
@@ -3474,7 +3474,7 @@ class cppfront
3474
3474
}
3475
3475
3476
3476
auto print = print_to_string (
3477
- *i->id_expr ,
3477
+ *i->id_expr ,
3478
3478
false , // not a local name
3479
3479
i->op ->type () == lexeme::Dot || i->op ->type () == lexeme::DotDot // member access
3480
3480
);
@@ -4362,7 +4362,8 @@ class cppfront
4362
4362
parameter_declaration_node const & n,
4363
4363
bool is_returns = false ,
4364
4364
bool is_template_parameter = false ,
4365
- bool is_statement = false
4365
+ bool is_statement = false ,
4366
+ bool emit_identifier = true
4366
4367
)
4367
4368
-> void
4368
4369
{ STACKINSTR
@@ -4406,8 +4407,8 @@ class cppfront
4406
4407
{
4407
4408
assert (n.declaration );
4408
4409
auto is_param_to_namespace_scope_type =
4409
- n.declaration ->parent_is_type ()
4410
- && n.declaration ->parent_declaration ->parent_is_namespace ()
4410
+ n.declaration ->parent_is_type ()
4411
+ && n.declaration ->parent_declaration ->parent_is_namespace ()
4411
4412
;
4412
4413
4413
4414
auto emit_in_phase_0 =
@@ -4524,7 +4525,7 @@ class cppfront
4524
4525
printer.print_cpp2 ( unnamed_type_param_name (n.ordinal , n.declaration ->identifier ->get_token ()),
4525
4526
identifier_pos );
4526
4527
}
4527
- else {
4528
+ else if (emit_identifier) {
4528
4529
printer.print_cpp2 ( identifier, identifier_pos );
4529
4530
}
4530
4531
};
@@ -4537,6 +4538,20 @@ class cppfront
4537
4538
return ;
4538
4539
}
4539
4540
4541
+ // -----------------------------------------------------------------------
4542
+ // Handle template parameters
4543
+
4544
+ if (n.declaration ->is_template ()) {
4545
+ printer.print_cpp2 (" template " , identifier_pos);
4546
+ emit (*n.declaration ->template_parameters , is_returns, true , false , false );
4547
+ printer.print_cpp2 (" class" , identifier_pos);
4548
+ if (emit_identifier) {
4549
+ printer.print_cpp2 (" " , identifier_pos);
4550
+ printer.print_cpp2 ( identifier, identifier_pos );
4551
+ }
4552
+ return ;
4553
+ }
4554
+
4540
4555
// -----------------------------------------------------------------------
4541
4556
// Else handle template non-type parameters
4542
4557
@@ -4760,7 +4775,8 @@ class cppfront
4760
4775
parameter_declaration_list_node const & n,
4761
4776
bool is_returns = false ,
4762
4777
bool is_template_parameter = false ,
4763
- bool generating_postfix_inc_dec = false
4778
+ bool generating_postfix_inc_dec = false ,
4779
+ bool emit_identifier = true
4764
4780
)
4765
4781
-> void
4766
4782
{ STACKINSTR
@@ -4789,7 +4805,7 @@ class cppfront
4789
4805
}
4790
4806
prev_pos = x->position ();
4791
4807
assert (x);
4792
- emit (*x, is_returns, is_template_parameter);
4808
+ emit (*x, is_returns, is_template_parameter, false , emit_identifier );
4793
4809
if (!x->declaration ->has_name (" this" )) {
4794
4810
first = false ;
4795
4811
}
@@ -5033,7 +5049,7 @@ class cppfront
5033
5049
|| n.is_swap ()
5034
5050
|| n.is_destructor ()
5035
5051
|| (
5036
- n.my_decl
5052
+ n.my_decl
5037
5053
&& generating_move_from == n.my_decl
5038
5054
)
5039
5055
)
@@ -5047,7 +5063,7 @@ class cppfront
5047
5063
if (
5048
5064
n.is_assignment ()
5049
5065
|| (
5050
- n.my_decl
5066
+ n.my_decl
5051
5067
&& generating_assignment_from == n.my_decl
5052
5068
)
5053
5069
)
@@ -6935,8 +6951,8 @@ class cppfront
6935
6951
return ;
6936
6952
}
6937
6953
}
6938
- printer.preempt_position_push (n.position ());
6939
- emit ( *type, {}, print_to_string (*n.identifier ) );
6954
+ printer.preempt_position_push (n.position ());
6955
+ emit ( *type, {}, print_to_string (*n.identifier ) );
6940
6956
printer.preempt_position_pop ();
6941
6957
6942
6958
if (
0 commit comments