diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-07-09 10:20:25 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-07-09 10:20:25 -0400 |
commit | 2c699fd29829cd6115f78238dab7cab74f0a5009 (patch) | |
tree | 736e4d48fa994c1f2485c5badcfe363da30c5c4d /gcc/ada/gcc-interface/utils.c | |
parent | f53e66019df819f55d424cc56f8b0ea81c074b55 (diff) | |
download | gcc-2c699fd29829cd6115f78238dab7cab74f0a5009.zip gcc-2c699fd29829cd6115f78238dab7cab74f0a5009.tar.gz gcc-2c699fd29829cd6115f78238dab7cab74f0a5009.tar.bz2 |
c++: requires-expr with dependent extra args [PR101181]
Here we're crashing ultimately because the mechanism for delaying
substitution into a requires-expression (and constexpr if and pack
expansions) doesn't expect to see dependent args. But we end up
capturing dependent args here during substitution into the default
template argument as part of coerce_template_parms for the dependent
specialization p<T>.
This patch enables the commented out code in add_extra_args for handling
this situation. This isn't needed for pack expansions (as the
accompanying comment points out), and it doesn't seem strictly necessary
for constexpr if either, but for requires-expressions delaying even
dependent substitution is important for ensuring we don't evaluate
requirements out of order.
It turns out we also need to make a copy of the arguments when capturing
them so that coerce_template_parms doesn't later add to them and form an
unexpected cycle (REQUIRES_EXPR_EXTRA_ARGS (t) would indirectly point to t).
We also need to make tsubst_template_args handle missing template
arguments, since the arguments we capture from coerce_template_parms
and are incomplete at that point.
PR c++/101181
gcc/cp/ChangeLog:
* constraint.cc (tsubst_requires_expr): Pass complain/in_decl to
add_extra_args.
* cp-tree.h (add_extra_args): Add complain/in_decl parameters.
* pt.c (build_extra_args): Make a copy of args.
(add_extra_args): Add complain/in_decl parameters. Enable the
code for handling the case where the extra arguments are
dependent.
(tsubst_pack_expansion): Pass complain/in_decl to
add_extra_args.
(tsubst_template_args): Handle missing template arguments.
(tsubst_expr) <case IF_STMT>: Pass complain/in_decl to
add_extra_args.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-requires26.C: New test.
* g++.dg/cpp2a/lambda-uneval16.C: New test.
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
0 files changed, 0 insertions, 0 deletions