diff options
author | Patrick Palka <ppalka@redhat.com> | 2024-09-07 14:06:37 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2024-09-07 14:06:37 -0400 |
commit | dfb63765e994bee74d533c810fdf75d3269530ad (patch) | |
tree | a960f31b31e6b9579047f4bccef2b40ca559ee63 /libobjc | |
parent | 506417dbc8b1cbc1133a5322572cf94b671aadf6 (diff) | |
download | gcc-dfb63765e994bee74d533c810fdf75d3269530ad.zip gcc-dfb63765e994bee74d533c810fdf75d3269530ad.tar.gz gcc-dfb63765e994bee74d533c810fdf75d3269530ad.tar.bz2 |
c++: deferring partial substitution into lambda [PR116567]
Here we correctly defer partial substitution into the lambda used as
a default template argument, but then incorrectly perform the full
substitution, because add_extra_args adds outer template arguments from
the full substitution that are not related to the original template
context of the lambda. For example, the template depth of the first
lambda is 1 but add_extra_args return a set of args with 3 levels, with
the inner level corresponding to the parameters of v1 (good) and the
outer levels corresponding to those of A and B (bad).
For the cases that we're interested in, add_extra_args can assume that
the deferred args are a full set of template arguments, and so it
suffices to just substitute into the deferred args and not do any
additional merging.
This patch refines add_extra_args accordingly, and additionally
makes it look for the tf_partial flag instead of for dependent args to
decide if the deferred substitution is a partial one. This reveals we
were neglecting to set tf_partial when substituting into a default
template argument in a template context.
PR c++/116567
gcc/cp/ChangeLog:
* pt.cc (coerce_template_parms): Set tf_partial when substituting
into a default template argument in a template context.
(build_extra_args): Set TREE_STATIC on the deferred args if this
is a partial substitution.
(add_extra_args): Check TREE_STATIC instead of dependence of args.
Adjust merging behavior in that case.
(tsubst_lammda_expr): Check for tf_partial instead of dependence
of args when determining whether to defer substitution.
(tsubst_expr) <case LAMBDA_EXPR>: Remove tf_partial early exit.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/lambda-targ7.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'libobjc')
0 files changed, 0 insertions, 0 deletions