@@ -2646,8 +2646,8 @@ extern void decl_shadowed_for_var_insert (tree, tree);
template info for the alias template, not the one (if any) for the
template of the underlying type. */
#define TYPE_TEMPLATE_INFO(NODE) \
- (TYPE_ALIAS_P (NODE) \
- ? ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE))) \
+ ((TYPE_ALIAS_P (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE))) \
+ ? (DECL_LANG_SPECIFIC (TYPE_NAME (NODE)) \
? DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) \
: NULL_TREE) \
: ((TREE_CODE (NODE) == ENUMERAL_TYPE) \
@@ -5437,7 +5437,7 @@ extern bool reregister_specialization (tree, tree, tree);
extern tree fold_non_dependent_expr (tree);
extern tree fold_non_dependent_expr_sfinae (tree, tsubst_flags_t);
extern bool alias_type_or_template_p (tree);
-extern bool alias_template_specialization_p (tree);
+extern bool alias_template_specialization_p (const_tree);
extern bool explicit_class_specialization_p (tree);
extern int push_tinst_level (tree);
extern void pop_tinst_level (void);
@@ -2929,10 +2929,7 @@ primary_template_instantiation_p (const_tree t)
else if (CLASS_TYPE_P (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
return CLASSTYPE_TEMPLATE_INSTANTIATION (t)
&& PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t));
- else if (TYPE_P (t)
- && TYPE_TEMPLATE_INFO (t)
- && PRIMARY_TEMPLATE_P (TYPE_TI_TEMPLATE (t))
- && DECL_TEMPLATE_INSTANTIATION (TYPE_NAME (t)))
+ else if (alias_template_specialization_p (t))
return true;
return false;
}
@@ -5077,11 +5074,14 @@ alias_type_or_template_p (tree t)
/* Return TRUE iff is a specialization of an alias template. */
bool
-alias_template_specialization_p (tree t)
+alias_template_specialization_p (const_tree t)
{
if (t == NULL_TREE)
return false;
- return (primary_template_instantiation_p (t)
+
+ return (TYPE_P (t)
+ && TYPE_TEMPLATE_INFO (t)
+ && PRIMARY_TEMPLATE_P (TYPE_TI_TEMPLATE (t))
&& DECL_ALIAS_TEMPLATE_P (TYPE_TI_TEMPLATE (t)));
}
@@ -10945,10 +10945,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
{
tree decl = TYPE_NAME (t);
- if (TYPE_DECL_ALIAS_P (decl)
- && DECL_LANG_SPECIFIC (decl)
- && DECL_TEMPLATE_INFO (decl)
- && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (decl)))
+ if (alias_template_specialization_p (t))
{
/* DECL represents an alias template and we want to
instantiate it. */
new file mode 100644
@@ -0,0 +1,24 @@
+// Origin: PR c++/53540
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+struct context
+{
+ typedef int type;
+};
+
+template <typename T>
+void function()
+{
+ using ctx1 = context<T>;
+ typename ctx1::type f1;
+
+ typedef context<T> ctx2;
+ typename ctx2::type f2;
+}
+
+int main()
+{
+ function<int>();
+}
+