]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: alias of alias tmpl with dependent attrs [PR115897]
authorPatrick Palka <ppalka@redhat.com>
Thu, 25 Jul 2024 23:00:23 +0000 (19:00 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 25 Jul 2024 23:00:23 +0000 (19:00 -0400)
commit9bcad238837e2100978cd839c343c488f72e1d4a
tree5f2fa7b9a2fa19fef0113711d3942ddc337ed6f7
parentdafd1247b10dbf47177cb81ad267fe569baf0b97
c++: alias of alias tmpl with dependent attrs [PR115897]

As a follow-up to r15-2047-g7954bb4fcb6fa8, we also need to consider
dependent attributes when recursing into a non-template alias that names
a dependent alias template specialization (and so STF_STRIP_DEPENDENT
is set), otherwise in the first testcase below we undesirably strip B
all the way to T instead of to A<T>.

We also need to move the typedef recursion case of strip_typedefs up to
get checked before the compound type recursion cases.  Otherwise for C
below (which ultimately aliases T*) we end up stripping it to T* instead
of to A<T*> because the POINTER_TYPE recursion dominates the typedef
recursion.  It also means we issue an unexpected extra error in the
third testcase below.

Ideally we would also want to consider dependent attributes on
non-template aliases, so that we accept the second testcase below, but
making that work correctly would require broader changes to e.g.
structural_comptypes.

PR c++/115897

gcc/cp/ChangeLog:

* tree.cc (strip_typedefs): Move up the typedef recursion case.
Never strip a dependent alias template-id that has dependent
attributes.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-78.C: New test.
* g++.dg/cpp0x/alias-decl-79.C: New test.
* g++.dg/cpp0x/alias-decl-pr92206-1a.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/tree.cc
gcc/testsuite/g++.dg/cpp0x/alias-decl-78.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/alias-decl-79.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/alias-decl-pr92206-1a.C [new file with mode: 0644]