]> git.ipfire.org Git - thirdparty/gcc.git/commit
cp/coroutines: do not rewrite parameters in unevaluated contexts
authorArsen Arsenović <arsen@aarsen.me>
Thu, 18 Jul 2024 16:16:49 +0000 (18:16 +0200)
committerIain Sandoe <iain@sandoe.co.uk>
Thu, 1 May 2025 15:44:17 +0000 (16:44 +0100)
commit074a89e4c5f9b237176626d464fcc494389905f6
treee91030ae36b683fa7b2b8956809aa7594bfde1a3
parentfbe351c9fa344cc53bff8a4e03068c7121af0d0c
cp/coroutines: do not rewrite parameters in unevaluated contexts

It is possible to use parameters of a parent function of a lambda in
unevaluated contexts without capturing them.  By not capturing them, we
work around the usual mechanism we use to prevent rewriting captured
parameters.  Prevent this by simply skipping rewrites in unevaluated
contexts.  Those won't mind the value not being present anyway.

This prevents an ICE during parameter substitution.  In the testcase
from the PR, the rewriting machinery finds a param in the body of the
coroutine, which it did not previously encounter while processing the
coroutine declaration, and that does not have a DECL_VALUE_EXPR, and
fails.

gcc/cp/ChangeLog:

PR c++/111728
* coroutines.cc (rewrite_param_uses): Skip unevaluated
subexpressions.

gcc/testsuite/ChangeLog:

PR c++/111728
* g++.dg/coroutines/pr111728.C: New test.

(cherry picked from commit 1a37d6b732506f8c3f9e9452c9dc6a456f25397b)
gcc/cp/coroutines.cc
gcc/testsuite/g++.dg/coroutines/pr111728.C [new file with mode: 0644]