Fix couple of endianness issues in fold_ctor_reference
commitdb5d70632a6cb59521e41df7745cacb08d00a3f4
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 30 Jun 2023 16:05:34 +0000 (30 18:05 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Fri, 30 Jun 2023 16:12:21 +0000 (30 18:12 +0200)
tree2b2d8019b85d7f5d2dddfc837a6e2def6fd26c38
parentc3c0ba5436170e01499f4390b7b628a32943a9e2
Fix couple of endianness issues in fold_ctor_reference

fold_ctor_reference attempts to use a recursive local processing in order
to call native_encode_expr on the leaf nodes of the constructor, before
falling back to calling native_encode_initializer if this fails.

There are a couple of issues related to endianness present in it:
  1) it does not specifically handle integral bit-fields; now these are left
justified on big-endian platforms so cannot be treated like ordinary fields.
  2) it does not check that the constructor uses the native storage order.

gcc/
* gimple-fold.cc (fold_array_ctor_reference): Fix head comment.
(fold_nonarray_ctor_reference): Likewise.  Specifically deal
with integral bit-fields.
(fold_ctor_reference): Make sure that the constructor uses the
native storage order.

gcc/testsuite/
* gcc.c-torture/execute/20230630-1.c: New test.
* gcc.c-torture/execute/20230630-2.c: Likewise.
* gcc.c-torture/execute/20230630-3.c: Likewise
* gcc.c-torture/execute/20230630-4.c: Likewise
gcc/gimple-fold.cc
gcc/testsuite/gcc.c-torture/execute/20230630-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/20230630-2.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/20230630-3.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/20230630-4.c [new file with mode: 0644]