Since we have a TYPENAME_TYPE cache, through which equivalent
TYPENAME_TYPEs are reused, in-place modification of a TYPENAME_TYPE is
generally unsafe. This is a latent issue noticed when attempting a
different approach to fix PR122752.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_template_id): Rebuild instead of modifying
a TYPENAME_TYPE corresponding to a dependently-scoped template.
Reviewed-by: Jason Merrill <jason@redhat.com>
&& TREE_CODE (TREE_TYPE (templ)) == TYPENAME_TYPE)
{
/* Some type template in dependent scope. */
- tree &name = TYPENAME_TYPE_FULLNAME (TREE_TYPE (templ));
- name = build_min_nt_loc (combined_loc,
- TEMPLATE_ID_EXPR,
- name, arguments);
+ tree fullname = TYPENAME_TYPE_FULLNAME (TREE_TYPE (templ));
+ fullname = build_min_nt_loc (combined_loc,
+ TEMPLATE_ID_EXPR,
+ fullname, arguments);
+ TREE_TYPE (templ)
+ = build_typename_type (TYPE_CONTEXT (TREE_TYPE (templ)),
+ TYPE_NAME (TREE_TYPE (templ)),
+ fullname,
+ get_typename_tag (TREE_TYPE (templ)));
template_id = templ;
}
else