else if (current_template_parms)
{
/* This is an argument of the current template, so we haven't set
- DECL_CONTEXT yet. */
+ DECL_CONTEXT yet. We can also get here when level-lowering a
+ bound ttp. */
tree relevant_template_parms;
/* Parameter levels that are greater than the level of the given
static tree
tsubst_template_decl (tree t, tree args, tsubst_flags_t complain,
- tree lambda_fntype)
+ tree lambda_fntype, tree lambda_tparms)
{
/* We can get here when processing a member function template,
member class template, or template template parameter. */
auto tparm_guard = make_temp_override (current_template_parms);
DECL_TEMPLATE_PARMS (r)
= current_template_parms
- = tsubst_template_parms (DECL_TEMPLATE_PARMS (t), args,
- complain);
+ = (lambda_tparms
+ ? lambda_tparms
+ : tsubst_template_parms (DECL_TEMPLATE_PARMS (t), args,
+ complain));
bool class_p = false;
tree inner = decl;
switch (TREE_CODE (t))
{
case TEMPLATE_DECL:
- r = tsubst_template_decl (t, args, complain, /*lambda*/NULL_TREE);
+ r = tsubst_template_decl (t, args, complain,
+ /*lambda_fntype=*/NULL_TREE,
+ /*lambda_tparms=*/NULL_TREE);
break;
case FUNCTION_DECL:
? DECL_TI_TEMPLATE (oldfn)
: NULL_TREE);
+ tree tparms = NULL_TREE;
+ if (oldtmpl)
+ tparms = tsubst_template_parms (DECL_TEMPLATE_PARMS (oldtmpl), args, complain);
+
tree fntype = static_fn_type (oldfn);
+
+ tree saved_ctp = current_template_parms;
if (oldtmpl)
- ++processing_template_decl;
+ {
+ ++processing_template_decl;
+ current_template_parms = tparms;
+ }
fntype = tsubst (fntype, args, complain, in_decl);
if (oldtmpl)
- --processing_template_decl;
+ {
+ current_template_parms = saved_ctp;
+ --processing_template_decl;
+ }
if (fntype == error_mark_node)
r = error_mark_node;
type_memfn_quals (fntype),
type_memfn_rqual (fntype));
tree inst = (oldtmpl
- ? tsubst_template_decl (oldtmpl, args, complain, fntype)
+ ? tsubst_template_decl (oldtmpl, args, complain,
+ fntype, tparms)
: tsubst_function_decl (oldfn, args, complain, fntype));
if (inst == error_mark_node)
{