RISC-V: Suppress -Wclass-memaccess warning
authorKito Cheng <kito.cheng@sifive.com>
Mon, 29 Aug 2022 02:28:28 +0000 (10:28 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Mon, 29 Aug 2022 02:32:21 +0000 (10:32 +0800)
commit7b9b6969a99725a171ee0ad4006cc39b0f7abf77
treeaab6f027e76c1201a52ae50c4cc4a612baf2c1eb
parent31380d4b7925912b9c34afe8cdb8dffe6cd50b94
RISC-V: Suppress -Wclass-memaccess warning

poly_int64 is non-trivial type, we need to clean up manully instead
of memset to prevent this warning.

../../gcc/gcc/config/riscv/riscv.cc: In function 'void riscv_compute_frame_info()':
../../gcc/gcc/config/riscv/riscv.cc:4113:10: error: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct riscv_frame_info'; use assignment or value-initialization instead [-Werror=class-memaccess]
 4113 |   memset (frame, 0, sizeof (*frame));
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/config/riscv/riscv.cc:101:17: note: 'struct riscv_frame_info' declared here
  101 | struct GTY(())  riscv_frame_info {
      |                 ^~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_frame_info): Introduce `reset(void)`;
(riscv_frame_info::reset(void)): New.
(riscv_compute_frame_info): Use riscv_frame_info::reset instead
of memset when clean frame.
gcc/config/riscv/riscv.cc