/* Calculate the complete set of arguments used to
specialize R. */
- if (use_spec_table)
+ if (use_spec_table && !lambda_fntype)
{
argvec = tsubst_template_args (DECL_TI_ARGS
(DECL_TEMPLATE_RESULT
return error_mark_node;
/* Check to see if we already have this specialization. */
- if (!lambda_fntype)
- {
- hash = spec_hasher::hash (gen_tmpl, argvec);
- if (tree spec = retrieve_specialization (gen_tmpl, argvec, hash))
- /* The spec for these args might be a partial instantiation of the
- template, but here what we want is the FUNCTION_DECL. */
- return STRIP_TEMPLATE (spec);
- }
+ hash = spec_hasher::hash (gen_tmpl, argvec);
+ if (tree spec = retrieve_specialization (gen_tmpl, argvec, hash))
+ /* The spec for these args might be a partial instantiation of the
+ template, but here what we want is the FUNCTION_DECL. */
+ return STRIP_TEMPLATE (spec);
}
else
argvec = args;
/* Type partial instantiations are stored as the type by
lookup_template_class_1, not here as the template. */
spec = CLASSTYPE_TI_TEMPLATE (spec);
+ else if (TREE_CODE (spec) != TEMPLATE_DECL)
+ spec = DECL_TI_TEMPLATE (spec);
return spec;
}
}
inner = tsubst_aggr_type (inner, args, complain,
in_decl, /*entering*/1);
else
- inner = tsubst (inner, args, complain, in_decl);
+ inner = tsubst_decl (inner, args, complain, /*use_spec_table=*/false);
}
--processing_template_decl;
if (inner == error_mark_node)
}
else
{
- if (TREE_CODE (inner) == FUNCTION_DECL)
- /* Set DECL_TI_ARGS to the full set of template arguments, which
- tsubst_function_decl didn't do due to use_spec_table=false. */
- DECL_TI_ARGS (inner) = full_args;
-
DECL_TI_TEMPLATE (inner) = r;
+ /* Set DECL_TI_ARGS to the full set of template arguments,
+ which tsubst_function_decl / tsubst_decl didn't do due to
+ use_spec_table=false. */
+ DECL_TI_ARGS (inner) = full_args;
DECL_TI_ARGS (r) = DECL_TI_ARGS (inner);
}
if (PRIMARY_TEMPLATE_P (t))
DECL_PRIMARY_TEMPLATE (r) = r;
- if (TREE_CODE (decl) == FUNCTION_DECL && !lambda_fntype)
- /* Record this non-type partial instantiation. */
- register_specialization (r, t, full_args, false, hash);
+ if (!lambda_fntype && !class_p)
+ {
+ /* Record this non-type partial instantiation. */
+ /* FIXME we'd like to always register the TEMPLATE_DECL, or always
+ the DECL_TEMPLATE_RESULT, but it seems the modules code relies
+ on this current behavior. */
+ if (TREE_CODE (inner) == FUNCTION_DECL)
+ register_specialization (r, t, full_args, false, hash);
+ else
+ register_specialization (inner, t, full_args, false, hash);
+ }
return r;
}