From f3902087886bb96c861224bf43fc39538d0ad9c5 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Wed, 22 Nov 2023 12:26:57 -0500 Subject: [PATCH] c++: alias template of non-template class [PR112633] Bootstrapped and regtested on x86-64-pc-linux-gnu, does this look OK for trunk/13? -- >8 -- The entering_scope adjustment in tsubst_aggr_type assumes if an alias is dependent, then so is the aliased type (and therefore it has template info) but that's not true for the dependent alias template specialization ty1 below which aliases the non-template class A. PR c++/112633 gcc/cp/ChangeLog: * pt.cc (tsubst_aggr_type): Handle empty TYPE_TEMPLATE_INFO in the entering_scope adjustment. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alias-decl-75.C: New test. --- gcc/cp/pt.cc | 1 + gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 351fc18b600b..d135764278df 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -13978,6 +13978,7 @@ tsubst_aggr_type (tree t, if (entering_scope && CLASS_TYPE_P (t) && dependent_type_p (t) + && TYPE_TEMPLATE_INFO (t) && TYPE_CANONICAL (t) == TREE_TYPE (TYPE_TI_TEMPLATE (t))) t = TYPE_CANONICAL (t); diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C new file mode 100644 index 000000000000..1a73a99856e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C @@ -0,0 +1,13 @@ +// PR c++/112633 +// { dg-do compile { target c++11 } } + +struct A { using type = void; }; + +template +using ty1 = A; + +template +using ty2 = typename ty1::type; + +template +ty2 f();