]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: non-template alias with dependent attributes [PR115897]
authorPatrick Palka <ppalka@redhat.com>
Thu, 25 Jul 2024 23:05:19 +0000 (19:05 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 25 Jul 2024 23:05:19 +0000 (19:05 -0400)
commit523836716137d0f7f4088c85752a980f5f971b36
treed23dc2a57c10495d0554d31d6eebe0e7a911adf7
parent9bcad238837e2100978cd839c343c488f72e1d4a
c++: non-template alias with dependent attributes [PR115897]

This patch generalizes our support for dependent attributes on alias
templates to also support them on non-template aliases.  The main
addition is a new predicate dependent_opaque_alias_p controlling whether
we can treat an alias (template or non-template) as type-equivalent to
its expansion.

PR c++/115897

gcc/cp/ChangeLog:

* cp-tree.h (dependent_opaque_alias_p): Declare.
* pt.cc (push_template_decl): Manually mark a dependent opaque
alias or dependent alias template specialization as dependent,
and use structural equality for them.
(dependent_opaque_alias_p): Define.
(alias_template_specialization_p): Don't look through an
opaque alias.
(complex_alias_template_p): Use dependent_opaque_alias_p instead of
any_dependent_template_arguments_p directly.
(dependent_alias_template_spec_p): Don't look through an
opaque alias.
(get_underlying_template): Use dependent_opaque_alias_p instead of
any_dependent_template_arguments_p.
(instantiate_alias_template): Mention same logic in
push_template_decl.
(dependent_type_p_r): Remove dependent_alias_template_spec_p check.
(any_template_arguments_need_structural_equality_p): Return true
for a dependent opaque alias.
(alias_ctad_tweaks): Use template_args_equal instead of same_type_p
followed by dependent_alias_template_spec_p.
* tree.cc (strip_typedefs): Don't strip an opaque alias.
* typeck.cc (structural_comptypes): Compare declaration attributes
for an opaque alias.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-79.C: Remove xfails.
* g++.dg/cpp0x/alias-decl-79a.C: New test.

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