? TYPE_ALIAS_TEMPLATE_INFO (NODE) \
: TYPE_TEMPLATE_INFO (NODE))
-/* Set the template information for an ENUMERAL_, RECORD_, or
- UNION_TYPE to VAL. */
+/* Set the template information for a non-alias n ENUMERAL_, RECORD_,
+ or UNION_TYPE to VAL. ALIAS's are dealt with separately. */
#define SET_TYPE_TEMPLATE_INFO(NODE, VAL) \
- (TREE_CODE (NODE) == ENUMERAL_TYPE \
- || (CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE)) \
- ? (TYPE_LANG_SLOT_1 (NODE) = (VAL)) \
- : (DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) = (VAL)))
+ (gcc_checking_assert (TREE_CODE (NODE) == ENUMERAL_TYPE \
+ || (CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE))), \
+ (TYPE_LANG_SLOT_1 (NODE) = (VAL))) \
#define TI_TEMPLATE(NODE) \
((struct tree_template_info*)TEMPLATE_INFO_CHECK (NODE))->tmpl
}
}
- // Build template info for the new specialization.
- SET_TYPE_TEMPLATE_INFO (t, build_template_info (found, arglist));
+ /* Build template info for the new specialization. */
+ if (TYPE_ALIAS_P (t))
+ {
+ /* This is constructed during instantiation of the alias
+ decl. But for member templates of template classes, that
+ is not correct as we need to refer to the partially
+ instantiated template, not the most general template.
+ The incorrect knowledge will not have escaped this
+ instantiation process, so we're good just updating the
+ template_info we made then. */
+ tree ti = DECL_TEMPLATE_INFO (TYPE_NAME (t));
+ gcc_checking_assert (template_args_equal (TI_ARGS (ti), arglist));
+ if (TI_TEMPLATE (ti) != found)
+ {
+ gcc_checking_assert (DECL_TI_TEMPLATE (found) == TI_TEMPLATE (ti));
+ TI_TEMPLATE (ti) = found;
+ }
+ }
+ else
+ SET_TYPE_TEMPLATE_INFO (t, build_template_info (found, arglist));
elt.spec = t;
slot = type_specializations->find_slot_with_hash (&elt, hash, INSERT);