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++/107065] GCC treats rvalue as an lvalue Date: Tue, 02 May 2023 20:12:45 +0000 [thread overview] Message-ID: <bug-107065-4-R8vusOWaPH@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107065-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107065 --- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:200854895c55ec999f38fce9086e711173a4a01a commit r11-10689-g200854895c55ec999f38fce9086e711173a4a01a Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Dec 15 19:17:45 2022 +0100 c++: Ensure !!var is not an lvalue [PR107065] The TRUTH_NOT_EXPR case in cp_build_unary_op is one of the spots where we somewhat fold immediately using invert_truthvalue_loc. I've tried using return build1_loc (location, TRUTH_NOT_EXPR, boolean_type_node, arg); in there instead, but unfortunately that regressed Wlogical-not-parentheses-*.c pr49706.c pr62199.c pr65120.c sequence-pt-1.C tests, so at least for backporting that doesn't seem to be a way to go. So, this patch instead wraps it into NON_LVALUE_EXPR if needed (which also need a tweak for some tests in the pr47906.c test, but nothing major), with the intent to make it backportable, and later I'll try to do further steps to avoid folding here prematurely. Most of the problems with build1 TRUTH_NOT_EXPR are that it doesn't even invert comparisons as most common case and lots of warning code isn't able to deal with ! around comparisons; so perhaps one way to do this would be fold by hand only invertable comparisons and for the rest create TRUTH_NOT_EXPR. 2022-12-15 Jakub Jelinek <jakub@redhat.com> PR c++/107065 gcc/cp/ * typeck.c (cp_build_unary_op) <case TRUTH_NOT_EXPR>: If invert_truthvalue_loc returns obvalue_p, wrap it into NON_LVALUE_EXPR. * parser.c (cp_parser_binary_expression): Don't call warn_logical_not_parentheses if current.lhs is a NON_LVALUE_EXPR of a decl with boolean type. gcc/testsuite/ * g++.dg/cpp0x/pr107065.C: New test. (cherry picked from commit 8b775b4c48a3cc4ef5c50e56144aea02da2e9cc6)
next prev parent reply other threads:[~2023-05-02 20:12 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-28 7:35 [Bug c++/107065] New: GCC treats rvalue like lvalue jlame646 at gmail dot com 2022-09-28 12:00 ` [Bug c++/107065] GCC treats rvalue as an lvalue redi at gcc dot gnu.org 2022-09-28 12:06 ` jlame646 at gmail dot com 2022-09-28 12:09 ` jlame646 at gmail dot com 2022-09-28 12:50 ` redi at gcc dot gnu.org 2022-09-28 13:41 ` mpolacek at gcc dot gnu.org 2022-09-28 14:32 ` jlame646 at gmail dot com 2022-09-28 15:34 ` mpolacek at gcc dot gnu.org 2022-09-29 18:24 ` glisse at gcc dot gnu.org 2022-09-29 19:01 ` jakub at gcc dot gnu.org 2022-09-30 7:12 ` jakub at gcc dot gnu.org 2022-09-30 7:13 ` jakub at gcc dot gnu.org 2022-09-30 8:03 ` glisse at gcc dot gnu.org 2022-09-30 8:27 ` jakub at gcc dot gnu.org 2022-09-30 8:47 ` glisse at gcc dot gnu.org 2022-12-15 18:18 ` cvs-commit at gcc dot gnu.org 2022-12-16 9:23 ` jakub at gcc dot gnu.org 2023-02-10 17:44 ` cvs-commit at gcc dot gnu.org 2023-05-02 20:12 ` cvs-commit at gcc dot gnu.org [this message] 2023-05-03 15:19 ` cvs-commit at gcc dot gnu.org 2023-05-04 7:20 ` 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-107065-4-R8vusOWaPH@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).