]> gcc.gnu.org Git - gcc.git/commit
fold-const: Handle NON_LVALUE_EXPR in native_encode_initializer [PR114537]
authorJakub Jelinek <jakub@redhat.com>
Thu, 4 Apr 2024 08:47:52 +0000 (10:47 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 11 Jun 2024 10:35:34 +0000 (12:35 +0200)
commit42afabb838d511f5feb150bfa4e68b5880aae1fa
tree50fd7d0ad65d2d9a72e2471bf472af896e7d283c
parent9987fe67cf6211515d8ebf6528cc83c77dfb5bf3
fold-const: Handle NON_LVALUE_EXPR in native_encode_initializer [PR114537]

The following testcase is incorrectly rejected.  The problem is that
for bit-fields native_encode_initializer expects the corresponding
CONSTRUCTOR elt value must be INTEGER_CST, but that isn't the case
here, it is wrapped into NON_LVALUE_EXPR by maybe_wrap_with_location.
We could STRIP_ANY_LOCATION_WRAPPER as well, but as all we are looking for
is INTEGER_CST inside, just looking through NON_LVALUE_EXPR seems easier.

2024-04-04  Jakub Jelinek  <jakub@redhat.com>

PR c++/114537
* fold-const.cc (native_encode_initializer): Look through
NON_LVALUE_EXPR if val is INTEGER_CST.

* g++.dg/cpp2a/bit-cast16.C: New test.

(cherry picked from commit 1baec8deb014b8a7da58879a407a4c00cdeb5a09)
gcc/fold-const.cc
gcc/testsuite/g++.dg/cpp2a/bit-cast16.C [new file with mode: 0644]
This page took 0.051191 seconds and 6 git commands to generate.