diff options
author | Arsen Arsenović <arsen@aarsen.me> | 2024-09-20 13:13:02 +0200 |
---|---|---|
committer | Arsen Arsenović <arsen@gcc.gnu.org> | 2024-09-27 13:37:37 +0200 |
commit | de03ef6337b0a368d61c74b790313b4216c7ed6e (patch) | |
tree | 5e56f3e15bde60e69338bfc637f1a42c62168b50 /gcc/java | |
parent | 05e4f07cad1eacf869c10622cae2a9cdee3b6a7a (diff) | |
download | gcc-de03ef6337b0a368d61c74b790313b4216c7ed6e.zip gcc-de03ef6337b0a368d61c74b790313b4216c7ed6e.tar.gz gcc-de03ef6337b0a368d61c74b790313b4216c7ed6e.tar.bz2 |
c++: simplify handling implicit INDIRECT_REF and co_await in convert_to_void
convert_to_void has, so far, when converting a co_await expression to
void altered the await_resume expression of a co_await so that it is
also converted to void. This meant that the type of the await_resume
expression, which is also supposed to be the type of the whole co_await
expression, was not the same as the type of the CO_AWAIT_EXPR tree.
While this has not caused problems so far, it is unexpected, I think.
Also, convert_to_void had a special case when an INDIRECT_REF wrapped a
CALL_EXPR. In this case, we also diagnosed maybe_warn_nodiscard. This
was a duplication of logic related to converting call expressions to
void.
Instead, we can generalize a bit, and rather discard the expression that
was implicitly dereferenced instead.
This patch changes the diagnostic of:
void f(struct S* x) { static_cast<volatile S&>(*x); }
... from:
warning: indirection will not access object of incomplete type
'volatile S' in statement
... to:
warning: implicit dereference will not access object of type
‘volatile S’ in statement
... but should have no impact in other cases.
gcc/cp/ChangeLog:
* coroutines.cc (co_await_get_resume_call): Return a tree
directly, rather than a tree pointer.
* cp-tree.h (co_await_get_resume_call): Adjust signature
accordingly.
* cvt.cc (convert_to_void): Do not alter CO_AWAIT_EXPRs when
discarding them. Simplify handling implicit INDIRECT_REFs.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/nodiscard-1.C: New test.
Diffstat (limited to 'gcc/java')
0 files changed, 0 insertions, 0 deletions