c++: Improve CTAD for aggregates [PR93976]
authorJason Merrill <jason@redhat.com>
Mon, 22 Jun 2020 19:44:45 +0000 (15:44 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 23 Jun 2020 21:49:44 +0000 (17:49 -0400)
commit6b161257f9f8c7a26b7d119ebc32cbbc54d2e508
tree7a4ecad39891e6b19eb3978fc96e543c2655e492
parent6f609029c7078fbd29e2f842074e2b99ea099096
c++: Improve CTAD for aggregates [PR93976]

P2082R1 adjusted the rules for class template argument deduction for an
aggregate to better handle arrays and pack expansions.

gcc/cp/ChangeLog:

PR c++/93976
Implement C++20 P2082R1, Fixing CTAD for aggregates.
* cp-tree.h (TPARMS_PRIMARY_TEMPLATE): Split out from...
(DECL_PRIMARY_TEMPLATE): ...here.
(builtin_guide_p): Declare.
* decl.c (reshape_init_class): Handle bases of a template.
(reshape_init_r): An array with dependent bound takes a single
initializer.
* pt.c (tsubst_default_argument): Shortcut {}.
(unify_pack_expansion): Allow omitted arguments to trailing pack.
(builtin_guide_p): New.
(collect_ctor_idx_types): Give a trailing pack a {} default
argument.  Handle arrays better.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-aggr3.C: New test.
* g++.dg/cpp2a/class-deduction-aggr4.C: New test.
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr4.C [new file with mode: 0644]