public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Kito Cheng <kito@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2243] RISC-V: Suppress -Wclass-memaccess warning Date: Mon, 29 Aug 2022 02:34:52 +0000 (GMT) [thread overview] Message-ID: <20220829023452.58B683858D1E@sourceware.org> (raw) https://gcc.gnu.org/g:7b9b6969a99725a171ee0ad4006cc39b0f7abf77 commit r13-2243-g7b9b6969a99725a171ee0ad4006cc39b0f7abf77 Author: Kito Cheng <kito.cheng@sifive.com> Date: Mon Aug 29 10:28:28 2022 +0800 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. Diff: --- gcc/config/riscv/riscv.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 6341dc98daa..4d439e15392 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -123,6 +123,9 @@ struct GTY(()) riscv_frame_info { /* The offset of arg_pointer_rtx from the bottom of the frame. */ poly_int64 arg_pointer_offset; + + /* Reset this struct, clean all field to zero. */ + void reset(void); }; enum riscv_privilege_levels { @@ -392,6 +395,23 @@ static const struct riscv_tune_info riscv_tune_info_table[] = { { "size", generic, &optimize_size_tune_info }, }; +void riscv_frame_info::reset(void) +{ + total_size = 0; + mask = 0; + fmask = 0; + save_libcall_adjustment = 0; + + gp_sp_offset = 0; + fp_sp_offset = 0; + + frame_pointer_offset = 0; + + hard_frame_pointer_offset = 0; + + arg_pointer_offset = 0; +} + /* Implement TARGET_MIN_ARITHMETIC_PRECISION. */ static unsigned int @@ -4179,7 +4199,7 @@ riscv_compute_frame_info (void) interrupt_save_prologue_temp = true; } - memset (frame, 0, sizeof (*frame)); + frame->reset(); if (!cfun->machine->naked_p) {
reply other threads:[~2022-08-29 2:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220829023452.58B683858D1E@sourceware.org \ --to=kito@gcc.gnu.org \ --cc=gcc-cvs@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).