@@ -11172,11 +11172,15 @@ vk_ext, ...) and, for vk_ext, its size_constant.
1117211172#endif /* GNU_VECTOR_TYPES_ALLOWED */
1117311173
1117411174a_type_ptr make_class_template_placeholder(a_symbol_ptr class_template,
11175- a_source_position *pos)
11175+ a_source_position *pos,
11176+ /* Defaulted: */ a_symbol_ptr bound_template)
1117611177/*
1117711178Create a type entry representing a class template used for C++ 17 class
1117811179template argument deduction. The result is a special kind of tk_template_param
11179- entry. pos is used to establish the type entry's position information.
11180+ entry. pos is used to establish the type entry's position information. When
11181+ class_template is a type template template parameter, bound_template (or the
11182+ current argument bound to class_template if bound_template is NULL) is recorded
11183+ in the supplement's template_symbol field.
1118011184*/
1118111185{
1118211186 a_symbol_ptr sym;
@@ -11188,6 +11192,16 @@ entry. pos is used to establish the type entry's position information.
1118811192 a_template_symbol_supplement_ptr
1118911193 tssp = template_supplement_for_symbol(class_template);
1119011194
11195+ if (bound_template == NULL) {
11196+ /* When not created by placeholder substitution, check whether an enclosing
11197+ instantiation has bound an argument to a template template parameter
11198+ (when unbound, argument_template points to class_template itself). */
11199+ a_symbol_ptr arg_sym = template_argument_if_template_template_param(
11200+ class_template);
11201+ if (arg_sym != class_template) {
11202+ bound_template = arg_sym;
11203+ } /* if */
11204+ } /* if */
1119111205 if (!alias_ctad_enabled && alias_ctad_allowed &&
1119211206 is_alias_template_symbol(class_template)) {
1119311207 if (clang_mode ||
@@ -11210,7 +11224,11 @@ entry. pos is used to establish the type entry's position information.
1121011224 sym->decl_scope = class_template->decl_scope;
1121111225 sym->variant.type.ptr = type;
1121211226 tpcp->depth = CLASS_TEMPLATE_PLACEHOLDER_NESTING_DEPTH;
11227+ /* For a template template parameter, CTAD keeps using the parameter's own
11228+ parameter list and defaults, while substitution goes through the template
11229+ bound to it. */
1121311230 tptsp->constraint.class_template_symbol = class_template;
11231+ tptsp->template_symbol = bound_template;
1121411232 set_type_size(type);
1121511233 set_source_corresp(&type->source_corresp, sym);
1121611234 if (!class_template->is_error &&
0 commit comments