to run the initializer.
If the initializer is a conditional expression, we need to collect
and declare any promoted variables nested within it. DTORs for such
- variables must be run conditionally too. */
+ variables must be run conditionally too.
+
+ Since here we're synthetically processing code here, we've already
+ emitted any Wunused-result warnings. Below, however, we call
+ finish_expr_stmt, which will convert its operand to void, and could
+ result in such a diagnostic being emitted. To avoid that, convert to
+ void ahead of time. */
if (t->var)
{
tree var = t->var;
if (TREE_CODE (t->init) == COND_EXPR)
process_conditional (t, vlist);
else
- finish_expr_stmt (t->init);
+ finish_expr_stmt (convert_to_void (t->init, ICV_STATEMENT, tf_none));
if (tree cleanup = cxx_maybe_build_cleanup (var, tf_warning_or_error))
{
tree cl = build_stmt (sloc, CLEANUP_STMT, expr_list, cleanup, var);
if (TREE_CODE (t->init) == COND_EXPR)
process_conditional (t, vlist);
else
- finish_expr_stmt (t->init);
+ finish_expr_stmt (convert_to_void (t->init, ICV_STATEMENT, tf_none));
if (expr_list)
{
if (TREE_CODE (expr_list) != STATEMENT_LIST)
--- /dev/null
+// https://gcc.gnu.org/PR116502
+#include <coroutine>
+
+struct SuspendNever {
+ bool await_ready() noexcept;
+ void await_suspend(std::coroutine_handle<>) noexcept;
+ void await_resume() noexcept;
+};
+
+struct Coroutine;
+
+struct PromiseType {
+ Coroutine get_return_object();
+ SuspendNever initial_suspend();
+ SuspendNever final_suspend() noexcept;
+ void return_void();
+ void unhandled_exception();
+};
+
+struct Coroutine {
+ using promise_type = PromiseType;
+};
+
+struct Awaiter {
+ bool await_ready();
+ void await_suspend(std::coroutine_handle<>);
+ [[nodiscard]] int& await_resume();
+};
+
+Coroutine foo()
+{
+ co_await Awaiter {}; // { dg-warning "Wunused-result" }
+}
--- /dev/null
+// https://gcc.gnu.org/PR116502
+#include <coroutine>
+
+struct SuspendNever {
+ bool await_ready() noexcept;
+ void await_suspend(std::coroutine_handle<>) noexcept;
+ void await_resume() noexcept;
+};
+
+struct Coroutine;
+
+struct PromiseType {
+ Coroutine get_return_object();
+ SuspendNever initial_suspend();
+ SuspendNever final_suspend() noexcept;
+ void return_void();
+ void unhandled_exception();
+};
+
+struct Coroutine {
+ using promise_type = PromiseType;
+};
+
+struct Awaiter {
+ bool await_ready();
+ void await_suspend(std::coroutine_handle<>);
+ [[nodiscard]] int& await_resume();
+};
+
+Coroutine foo()
+{
+ (void)co_await Awaiter {};
+}