@@ -1255,7 +1255,7 @@ class cppfront
12551255
12561256 // Now we'll open the Cpp1 file
12571257 auto cpp1_filename = sourcefile.substr (0 , std::ssize (sourcefile) - 1 );
1258-
1258+
12591259 // Use explicit filename override if present,
12601260 // otherwise strip leading path
12611261 if (!flag_cpp1_filename.empty ()) {
@@ -3428,12 +3428,12 @@ class cppfront
34283428 last_was_prefixed = true ;
34293429 }
34303430
3431- // Handle the other Cpp2 postfix operators that stay postfix in Cpp1
3431+ // Handle the other Cpp2 postfix operators that stay postfix in Cpp1
34323432 // (currently '...' for expansion, not when used as a range operator)
34333433 else if (
34343434 is_postfix_operator (i->op ->type ())
34353435 && !i->last_expr // not being used as a range operator
3436- )
3436+ )
34373437 {
34383438 flush_args ();
34393439 suffix.emplace_back ( i->op ->to_string (), i->op ->position ());
@@ -3474,7 +3474,7 @@ class cppfront
34743474 }
34753475
34763476 auto print = print_to_string (
3477- *i->id_expr ,
3477+ *i->id_expr ,
34783478 false , // not a local name
34793479 i->op ->type () == lexeme::Dot || i->op ->type () == lexeme::DotDot // member access
34803480 );
@@ -4362,7 +4362,8 @@ class cppfront
43624362 parameter_declaration_node const & n,
43634363 bool is_returns = false ,
43644364 bool is_template_parameter = false ,
4365- bool is_statement = false
4365+ bool is_statement = false ,
4366+ bool emit_identifier = true
43664367 )
43674368 -> void
43684369 { STACKINSTR
@@ -4406,8 +4407,8 @@ class cppfront
44064407 {
44074408 assert (n.declaration );
44084409 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 ()
44114412 ;
44124413
44134414 auto emit_in_phase_0 =
@@ -4524,7 +4525,7 @@ class cppfront
45244525 printer.print_cpp2 ( unnamed_type_param_name (n.ordinal , n.declaration ->identifier ->get_token ()),
45254526 identifier_pos );
45264527 }
4527- else {
4528+ else if (emit_identifier) {
45284529 printer.print_cpp2 ( identifier, identifier_pos );
45294530 }
45304531 };
@@ -4537,6 +4538,20 @@ class cppfront
45374538 return ;
45384539 }
45394540
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+
45404555 // -----------------------------------------------------------------------
45414556 // Else handle template non-type parameters
45424557
@@ -4760,7 +4775,8 @@ class cppfront
47604775 parameter_declaration_list_node const & n,
47614776 bool is_returns = false ,
47624777 bool is_template_parameter = false ,
4763- bool generating_postfix_inc_dec = false
4778+ bool generating_postfix_inc_dec = false ,
4779+ bool emit_identifier = true
47644780 )
47654781 -> void
47664782 { STACKINSTR
@@ -4789,7 +4805,7 @@ class cppfront
47894805 }
47904806 prev_pos = x->position ();
47914807 assert (x);
4792- emit (*x, is_returns, is_template_parameter);
4808+ emit (*x, is_returns, is_template_parameter, false , emit_identifier );
47934809 if (!x->declaration ->has_name (" this" )) {
47944810 first = false ;
47954811 }
@@ -5033,7 +5049,7 @@ class cppfront
50335049 || n.is_swap ()
50345050 || n.is_destructor ()
50355051 || (
5036- n.my_decl
5052+ n.my_decl
50375053 && generating_move_from == n.my_decl
50385054 )
50395055 )
@@ -5047,7 +5063,7 @@ class cppfront
50475063 if (
50485064 n.is_assignment ()
50495065 || (
5050- n.my_decl
5066+ n.my_decl
50515067 && generating_assignment_from == n.my_decl
50525068 )
50535069 )
@@ -6935,8 +6951,8 @@ class cppfront
69356951 return ;
69366952 }
69376953 }
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 ) );
69406956 printer.preempt_position_pop ();
69416957
69426958 if (
0 commit comments