https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116502

Arsen Arsenović <arsen at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-08-27

--- Comment #1 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
thanks for the report!

candidate patchlet:

modified   gcc/cp/coroutines.cc
@@ -3423,7 +3423,14 @@ maybe_promote_temps (tree *stmt, void *d)
         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;
@@ -3433,7 +3440,7 @@ maybe_promote_temps (tree *stmt, void *d)
          if (TREE_CODE (t->init) == COND_EXPR)
            process_conditional (t, vlist);
          else
-           finish_expr_stmt (t->init);
+           finish_expr_stmt (build1 (CONVERT_EXPR, void_type_node, t->init));
          if (tree cleanup = cxx_maybe_build_cleanup (var,
tf_warning_or_error))
            {
              tree cl = build_stmt (sloc, CLEANUP_STMT, expr_list, cleanup,
var);
@@ -3452,7 +3459,7 @@ maybe_promote_temps (tree *stmt, void *d)
          if (TREE_CODE (t->init) == COND_EXPR)
            process_conditional (t, vlist);
          else
-           finish_expr_stmt (t->init);
+           finish_expr_stmt (build1 (CONVERT_EXPR, void_type_node, t->init));
          if (expr_list)
            {
              if (TREE_CODE (expr_list) != STATEMENT_LIST)

Reply via email to