diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-05-10 22:33:04 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-05-10 22:33:04 -0400 |
commit | e7a9f085ffd34b0d7bc4b803c182b41494f609aa (patch) | |
tree | a2acd25d921ca506cd34aaf135a903739d809b20 /gcc/cp/pt.c | |
parent | aa891c56f25baac94db004e309d1b6e40b770a95 (diff) | |
download | gcc-e7a9f085ffd34b0d7bc4b803c182b41494f609aa.zip gcc-e7a9f085ffd34b0d7bc4b803c182b41494f609aa.tar.gz gcc-e7a9f085ffd34b0d7bc4b803c182b41494f609aa.tar.bz2 |
c++: fn parm pack expansion inside constraint [PR100138]
This PR is about CTAD but the underlying problems are more general;
CTAD is a good trigger for them because of the necessary substitution
into constraints that deduction guide generation entails.
In the testcase below, when generating the implicit deduction guide for
the constrained constructor template for A, we substitute the generic
flattening map 'tsubst_args' into the constructor's constraints. During
this substitution, tsubst_pack_expansion returns a rebuilt pack
expansion for sizeof...(xs), but doesn't carry over the
PACK_EXPANSION_LOCAL_P (and PACK_EXPANSION_SIZEOF_P) flag from the
original tree to the rebuilt one. The flag is otherwise unset on the
original tree but gets set for the rebuilt tree from make_pack_expansion
since at_function_scope_p() is true (we're inside main). This leads to
a crash during satisfaction when substituting into the pack expansion
because we don't have local_specializations set up (and it'd be set up
for us if PACK_EXPANSION_LOCAL_P is unset)
Similarly, tsubst_constraint needs to set cp_unevaluated so that the
substitution performed therein doesn't rely on local_specializations.
This avoids a crash during CTAD for C below.
gcc/cp/ChangeLog:
PR c++/100138
* constraint.cc (tsubst_constraint): Set up cp_unevaluated.
(satisfy_atom): Set up iloc_sentinel before calling
cxx_constant_value.
* pt.c (tsubst_pack_expansion): When returning a rebuilt pack
expansion, carry over PACK_EXPANSION_LOCAL_P and
PACK_EXPANSION_SIZEOF_P from the original pack expansion.
gcc/testsuite/ChangeLog:
PR c++/100138
* g++.dg/cpp2a/concepts-ctad4.C: New test.
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bd99529..85c05af 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13203,6 +13203,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, else result = tsubst (pattern, args, complain, in_decl); result = make_pack_expansion (result, complain); + PACK_EXPANSION_LOCAL_P (result) = PACK_EXPANSION_LOCAL_P (t); + PACK_EXPANSION_SIZEOF_P (result) = PACK_EXPANSION_SIZEOF_P (t); if (PACK_EXPANSION_AUTO_P (t)) { /* This is a fake auto... pack expansion created in add_capture with |