public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "arsen at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/116502] [15 Regression] -Wunused-result warning cannot be suppressed if coroutine awaiter returns a reference after r15-2318-g2664c1bf83855b
Date: Tue, 27 Aug 2024 17:43:56 +0000	[thread overview]
Message-ID: <bug-116502-4-UuW9JzbOr7@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-116502-4@http.gcc.gnu.org/bugzilla/>

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)

  parent reply	other threads:[~2024-08-27 17:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27 15:36 [Bug c++/116502] New: [15 Regression] -Wunused-result warning is not supressed if coroutine awaiter returns a reference daklishch at gmail dot com
2024-08-27 15:54 ` [Bug c++/116502] [15 Regression] -Wunused-result warning cannot be suppressed if coroutine awaiter returns a reference after r15-2318-g2664c1bf83855b pinskia at gcc dot gnu.org
2024-08-27 17:43 ` arsen at gcc dot gnu.org [this message]
2024-08-27 18:06 ` daklishch at gmail dot com
2024-09-02 13:34 ` arsen at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-116502-4-UuW9JzbOr7@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).