]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: nested aggregate/alias CTAD fixes [PR114974, PR114901, PR114903]
authorPatrick Palka <ppalka@redhat.com>
Mon, 13 May 2024 13:53:40 +0000 (09:53 -0400)
committerPatrick Palka <ppalka@redhat.com>
Mon, 13 May 2024 13:53:40 +0000 (09:53 -0400)
commit6d31a370e26eeb950c326332633b3e8e84b6630b
tree5edd98b499e7c65fab8a478eb393f47f232e4908
parent7d8946634c744af57c233a782840f52261e64911
c++: nested aggregate/alias CTAD fixes [PR114974, PR114901, PR114903]

During maybe_aggr_guide with a nested class template and paren init,
like with list init we need to consider the generic template type rather
than the partially instantiated type since partial instantiations don't
have (partially instantiated) TYPE_FIELDS.  In turn we need to partially
substitute PARMs in the paren init case as well.  As a drive-by improvement
it seems better to use outer_template_args instead of DECL_TI_ARGS during
this partial substitution so that we lower instead of substitute the
innermost template parameters, which is generally more robust.

And during alias_ctad_tweaks with a nested class template, even though
the guides may be already partially instantiated we still need to
substitute the outermost arguments into its constraints.

PR c++/114974
PR c++/114901
PR c++/114903

gcc/cp/ChangeLog:

* pt.cc (maybe_aggr_guide): Fix obtaining TYPE_FIELDS in
the paren init case.  Hoist out partial substitution logic
to apply to the paren init case as well.
(alias_ctad_tweaks): Substitute outer template arguments into
a guide's constraints.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-aggr14.C: New test.
* g++.dg/cpp2a/class-deduction-alias20.C: New test.
* g++.dg/cpp2a/class-deduction-alias21.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr14.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/class-deduction-alias20.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/class-deduction-alias21.C [new file with mode: 0644]