@@ -2605,17 +2605,24 @@ extern void decl_shadowed_for_var_insert (tree, tree);
(LANG_TYPE_CLASS_CHECK (BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK (NODE)) \
->template_info)
-/* Template information for an ENUMERAL_, RECORD_, or UNION_TYPE. */
+/* Template information for an ENUMERAL_, RECORD_, UNION_TYPE, or
+ BOUND_TEMPLATE_TEMPLATE_PARM type. Note that if NODE is a
+ specialization of an alias template, this accessor returns the
+ template info for the alias template, not the one (if any) for the
+ template of the underlying type. */
#define TYPE_TEMPLATE_INFO(NODE) \
- (TREE_CODE (NODE) == ENUMERAL_TYPE \
- ? ENUM_TEMPLATE_INFO (NODE) : \
- (TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM \
- ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) : \
- ((CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE)) \
- ? CLASSTYPE_TEMPLATE_INFO (NODE) \
- : ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE))) \
- ? (DECL_TEMPLATE_INFO (TYPE_NAME (NODE))) \
- : NULL_TREE))))
+ (TYPE_ALIAS_P (NODE) \
+ ? ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE))) \
+ ? DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) \
+ : NULL_TREE) \
+ : ((TREE_CODE (NODE) == ENUMERAL_TYPE) \
+ ? ENUM_TEMPLATE_INFO (NODE) \
+ : ((TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM) \
+ ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE) \
+ : (CLASS_TYPE_P (NODE) \
+ ? CLASSTYPE_TEMPLATE_INFO (NODE) \
+ : NULL_TREE))))
+
/* Set the template information for an ENUMERAL_, RECORD_, or
UNION_TYPE to VAL. */
@@ -3028,10 +3028,12 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
case BOUND_TEMPLATE_TEMPLATE_PARM:
/* Check the template itself. */
- cp_walk_tree (&TREE_TYPE (TYPE_TI_TEMPLATE (t)),
+ cp_walk_tree (&TREE_TYPE (TI_TEMPLATE
+ (TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t))),
&find_parameter_packs_r, ppd, ppd->visited);
/* Check the template arguments. */
- cp_walk_tree (&TYPE_TI_ARGS (t), &find_parameter_packs_r, ppd,
+ cp_walk_tree (&TI_ARGS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t)),
+ &find_parameter_packs_r, ppd,
ppd->visited);
*walk_subtrees = 0;
return NULL_TREE;
new file mode 100644
@@ -0,0 +1,13 @@
+// Origin PR c++/51289
+// { dg-options "-std=c++11" }
+
+template<typename a, template <typename, typename> class b>
+struct foo {
+ template <typename t>
+ using type = b<a, t>;
+ template <typename t>
+ b<a, t> funca() {}
+
+ template <typename t>
+ type<t> funcb() {}
+};