c++: remove coerce_innermost_template_parms
authorPatrick Palka <ppalka@redhat.com>
Sun, 20 Nov 2022 18:00:00 +0000 (13:00 -0500)
committerPatrick Palka <ppalka@redhat.com>
Sun, 20 Nov 2022 18:00:00 +0000 (13:00 -0500)
commitb36a5f8404d7c3681435b497ef6b27d69cba0a14
treec6f71d25985fe197a7a860950832921a5a921323
parent6b5c98c1c0003bd470a4428bede6c862637a94b8
c++: remove coerce_innermost_template_parms

The only practical difference between coerce_innermost_template_parms
and the main function coerce_template_parms is that the former accepts
a potentially multi-level parameter list and returns an argument vector
of the same depth, whereas the latter accepts only a single level of
parameters and only returns only a single level of arguments.  Both
functions accept a multi-level argument vector.

In light of this, it seems more natural to just overload the behavior of
the main function according to whether the given parameter list is
multi-level or not.  And it turns out we can assume the given parms and
args have the same depth in the multi-level case, which simplifies the
overloading logic.

Besides the simplification benefit, another benefit of this unification
is that it avoids an extra copy of a multi-level args since now we can
return new_args directly from c_t_p.  (And because of this, we need to
turn new_inner_args into a reference so that overwriting it also updates
new_args.)

gcc/cp/ChangeLog:

* pt.cc (coerce_template_parms): Salvage part of the function
comment from c_innermost_t_p.  Handle parms being a full
template parameter list.
(coerce_innermost_template_parms): Remove.
(lookup_template_class): Use c_t_p instead of c_innermost_t_p.
(finish_template_variable): Likewise.
(tsubst_decl): Likewise.
(instantiate_alias_template): Likewise.
gcc/cp/pt.cc