diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-02-08 08:46:13 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-02-08 08:46:13 -0500 |
commit | 34ba3d9a2bf72742b1c150a2dd17d10e3e3f0964 (patch) | |
tree | 96d3de214b499a8a4bcfab81c3b7031a429884f1 /gcc/cp/constraint.cc | |
parent | 61b783995fac5355827ada1f8544052119a23606 (diff) | |
download | gcc-34ba3d9a2bf72742b1c150a2dd17d10e3e3f0964.zip gcc-34ba3d9a2bf72742b1c150a2dd17d10e3e3f0964.tar.gz gcc-34ba3d9a2bf72742b1c150a2dd17d10e3e3f0964.tar.bz2 |
c++: constrained auto in lambda using outer tparms [PR103706]
Here we're crashing during satisfaction of the lambda's placeholder type
constraints because the constraints depend on the template arguments
from the enclosing scope, which aren't part of the lambda's DECL_TI_ARGS.
This patch fixes this by making do_auto_deduction consider the
"regenerating" template arguments of a lambda for satisfaction,
mirroring what's done in satisfy_declaration_constraints.
PR c++/103706
gcc/cp/ChangeLog:
* constraint.cc (satisfy_declaration_constraints): Use
lambda_regenerating_args instead.
* cp-tree.h (lambda_regenerating_args): Declare.
* pt.cc (lambda_regenerating_args): Define, split out from
satisfy_declaration_constraints.
(do_auto_deduction): Use lambda_regenerating_args to obtain the
full set of outer template arguments for satisfaction when
inside a lambda.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-lambda18.C: New test.
Diffstat (limited to 'gcc/cp/constraint.cc')
-rw-r--r-- | gcc/cp/constraint.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index cc4df42..b7b9439 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3154,12 +3154,11 @@ satisfy_declaration_constraints (tree t, sat_info info) set of template arguments. Augment this with the outer template arguments that were used to regenerate the lambda. */ gcc_assert (!args || TMPL_ARGS_DEPTH (args) == 1); - tree lambda = CLASSTYPE_LAMBDA_EXPR (DECL_CONTEXT (t)); - tree outer_args = TI_ARGS (LAMBDA_EXPR_REGEN_INFO (lambda)); + tree regen_args = lambda_regenerating_args (t); if (args) - args = add_to_template_args (outer_args, args); + args = add_to_template_args (regen_args, args); else - args = outer_args; + args = regen_args; } /* If any arguments depend on template parameters, we can't |