public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/97748] Preincrement of _Complex gives bogus warning = "value computed is not used" Date: Tue, 10 Nov 2020 14:58:16 +0000 [thread overview] Message-ID: <bug-97748-4-R9T8jWnD0t@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97748-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97748 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:0000ea4fb4eaacbd2c954d78d7f8e9f03c7be739 commit r11-4878-g0000ea4fb4eaacbd2c954d78d7f8e9f03c7be739 Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Nov 10 15:56:20 2020 +0100 c, c++: Fix up -Wunused-value on COMPLEX_EXPRs [PR97748] The -Wunused-value warning in both C and C++ FEs (implemented significantly differently between the two) sees the COMPLEX_EXPRs created e.g. for complex pre/post increment and many other expressions as useless and warns about it. For the C warning implementation, on e.g. COMPLEX_EXPR < ++REALPART_EXPR <x>, IMAGPART_EXPR <x>>; would warn even on the IMAGPART_EXPR <x> there alone etc., so what works is check if we'd warn about both operands of COMPLEX_EXPR and if yes, warn on the whole COMPLEX_EXPR, otherwise don't warn. The C++ warning implementation is significantly different and for that one the only warn if both would be warned about doesn't really work, we then miss warnings e.g. about COMPLEX_EXPR <REALPART_EXPR <SAVE_EXPR <x>> + 1.0e+0, IMAGPART_EXPR <SAVE_EXPR <x>>> >>>>> The patch replaces the warning_at call with call to the c-family warn_if_unused_value function. On the testcase which after the initial new tests contains pretty much everything from gcc.dg/Wunused-value-1.c both approaches seem to work nicely. 2020-11-10 Jakub Jelinek <jakub@redhat.com> PR c/97748 gcc/c-family/ * c-common.h (warn_if_unused_value): Add quiet argument defaulted to false. * c-warn.c (warn_if_unused_value): Likewise. Pass it down recursively and just return true instead of warning if it is true. Handle COMPLEX_EXPR. gcc/cp/ * cvt.c (convert_to_void): Check (complain & tf_warning) in the outer if rather than twice times in the inner one. Use warn_if_unused_value. Formatting fix. gcc/testsuite/ * c-c++-common/Wunused-value-1.c: New test.
next prev parent reply other threads:[~2020-11-10 14:58 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-06 23:21 [Bug c/97748] New: " antiquarktv at gmail dot com 2020-11-07 8:30 ` [Bug c/97748] " jakub at gcc dot gnu.org 2020-11-07 9:17 ` jakub at gcc dot gnu.org 2020-11-10 14:58 ` cvs-commit at gcc dot gnu.org [this message] 2020-11-12 10:06 ` cvs-commit at gcc dot gnu.org 2021-04-20 15:18 ` jakub 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-97748-4-R9T8jWnD0t@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: linkBe 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).