@@ -3219,7 +3219,7 @@ get_function_template_decl (const_tree primary_func_tmpl_inst)
32193219{
32203220 if (! primary_func_tmpl_inst
32213221 || TREE_CODE (primary_func_tmpl_inst) != FUNCTION_DECL
3222- || ! primary_template_instantiation_p (primary_func_tmpl_inst))
3222+ || ! primary_template_specialization_p (primary_func_tmpl_inst))
32233223 return NULL;
32243224
32253225 return DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (primary_func_tmpl_inst));
@@ -3287,21 +3287,23 @@ make_ith_pack_parameter_name (tree name, int i)
32873287}
32883288
32893289/* Return true if T is a primary function, class or alias template
3290- instantiation . */
3290+ specialization, not including the template pattern . */
32913291
32923292bool
3293- primary_template_instantiation_p (const_tree t)
3293+ primary_template_specialization_p (const_tree t)
32943294{
32953295 if (!t)
32963296 return false;
32973297
3298- if (TREE_CODE (t) == FUNCTION_DECL)
3299- return DECL_LANG_SPECIFIC (t)
3300- && DECL_TEMPLATE_INSTANTIATION (t)
3301- && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t));
3298+ if (TREE_CODE (t) == FUNCTION_DECL || VAR_P (t))
3299+ return (DECL_LANG_SPECIFIC (t)
3300+ && DECL_USE_TEMPLATE (t)
3301+ && DECL_TEMPLATE_INFO (t)
3302+ && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)));
33023303 else if (CLASS_TYPE_P (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
3303- return CLASSTYPE_TEMPLATE_INSTANTIATION (t)
3304- && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t));
3304+ return (CLASSTYPE_TEMPLATE_INFO (t)
3305+ && CLASSTYPE_USE_TEMPLATE (t)
3306+ && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t)));
33053307 else if (alias_template_specialization_p (t))
33063308 return true;
33073309 return false;
@@ -3336,7 +3338,7 @@ get_primary_template_innermost_parameters (const_tree t)
33363338 tree parms = NULL, template_info = NULL;
33373339
33383340 if ((template_info = get_template_info (t))
3339- && primary_template_instantiation_p (t))
3341+ && primary_template_specialization_p (t))
33403342 parms = INNERMOST_TEMPLATE_PARMS
33413343 (DECL_TEMPLATE_PARMS (TI_TEMPLATE (template_info)));
33423344
0 commit comments