From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 58636385E45D; Tue, 27 Aug 2024 17:43:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58636385E45D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1724780636; bh=k482728lr5bbQSmpvYsT8pDtytD6fzXyc8n/H4dCGPE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=li0sVj5ez7sZDppzCM/tejIKPcsLarKgdye09UkQlxFJyv4BJnE0dsshGSIn9fEgM yfymz6uBz2WIDFwjYGEb7hW3WrwhQC9fSAeKP+ZJFH7dN3z6deWl0s2VnqmUZJvqdo G1V271HsGeJCKOHrDlh5mDviomw83ek+msiKPhic= From: "arsen at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 15.0 X-Bugzilla-Keywords: c++-coroutines X-Bugzilla-Severity: normal X-Bugzilla-Who: arsen at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 15.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status everconfirmed cf_reconfirmed_on Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D116502 Arsen Arsenovi=C4=87 changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2024-08-27 --- Comment #1 from Arsen Arsenovi=C4=87 --- 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 su= ch - 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 =3D t->var; @@ -3433,7 +3440,7 @@ maybe_promote_temps (tree *stmt, void *d) if (TREE_CODE (t->init) =3D=3D 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 =3D cxx_maybe_build_cleanup (var, tf_warning_or_error)) { tree cl =3D build_stmt (sloc, CLEANUP_STMT, expr_list, cleanu= p, var); @@ -3452,7 +3459,7 @@ maybe_promote_temps (tree *stmt, void *d) if (TREE_CODE (t->init) =3D=3D 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) !=3D STATEMENT_LIST)=