]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: alias template of non-template class [PR112633]
authorPatrick Palka <ppalka@redhat.com>
Thu, 23 Nov 2023 00:07:19 +0000 (19:07 -0500)
committerPatrick Palka <ppalka@redhat.com>
Thu, 23 Nov 2023 00:07:19 +0000 (19:07 -0500)
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<T>
below which aliases the non-template class A.  In this case no adjustment
is needed anyway, so we can just punt.

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.

(cherry picked from commit 3f266c84a15d63e42bfad46397fea9aff92b0720)

gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C [new file with mode: 0644]

index 174567fc1ec48e24006c01e7d4440f1ef8a984ab..761df45f27498616f982c1a7efaa665820c3cf69 100644 (file)
@@ -14003,6 +14003,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 (file)
index 0000000..1a73a99
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/112633
+// { dg-do compile { target c++11 } }
+
+struct A { using type = void; };
+
+template<class>
+using ty1 = A;
+
+template<class T>
+using ty2 = typename ty1<T>::type;
+
+template<class T>
+ty2<T> f();