Skip to content

Commit

Permalink
c++: alias template of non-template class [PR112633]
Browse files Browse the repository at this point in the history
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<T>
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.
  • Loading branch information
Patrick Palka authored and ouuleilei-bot committed Nov 22, 2023
1 parent c2d62cd commit f390208
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions gcc/cp/pt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 13 additions & 0 deletions gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit f390208

Please sign in to comment.