diff mbox series

[Committed] RISC-V: Suppress warning

Message ID 20240120002739.2860933-1-juzhe.zhong@rivai.ai
State New
Headers show
Series [Committed] RISC-V: Suppress warning | expand

Commit Message

钟居哲 Jan. 20, 2024, 12:27 a.m. UTC
../../gcc/config/riscv/riscv.cc: In function 'void riscv_init_cumulative_args(CUMULATIVE_ARGS*, tree, rtx, tree, int)':
../../gcc/config/riscv/riscv.cc:4879:34: error: unused parameter 'fndecl' [-Werror=unused-parameter]
4879 |                             tree fndecl,
      |                             ~~~~~^~~~~~
../../gcc/config/riscv/riscv.cc: In function 'bool riscv_vector_mode_supported_any_target_p(machine_mode)':
../../gcc/config/riscv/riscv.cc:10537:56: error: unused parameter 'mode' [-Werror=unused-parameter]
10537 | riscv_vector_mode_supported_any_target_p (machine_mode mode)
      |                                           ~~~~~~~~~~~~~^~~~
cc1plus: all warnings being treated as errors
make[3]: *** [Makefile:2559: riscv.o] Error 1

Suppress these warnings.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_init_cumulative_args): Suppress warning.
	(riscv_vector_mode_supported_any_target_p): Ditto.

---
 gcc/config/riscv/riscv.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jeff Law Jan. 20, 2024, 12:52 a.m. UTC | #1
On 1/19/24 17:27, Juzhe-Zhong wrote:
> ../../gcc/config/riscv/riscv.cc: In function 'void riscv_init_cumulative_args(CUMULATIVE_ARGS*, tree, rtx, tree, int)':
> ../../gcc/config/riscv/riscv.cc:4879:34: error: unused parameter 'fndecl' [-Werror=unused-parameter]
> 4879 |                             tree fndecl,
>        |                             ~~~~~^~~~~~
> ../../gcc/config/riscv/riscv.cc: In function 'bool riscv_vector_mode_supported_any_target_p(machine_mode)':
> ../../gcc/config/riscv/riscv.cc:10537:56: error: unused parameter 'mode' [-Werror=unused-parameter]
> 10537 | riscv_vector_mode_supported_any_target_p (machine_mode mode)
>        |                                           ~~~~~~~~~~~~~^~~~
> cc1plus: all warnings being treated as errors
> make[3]: *** [Makefile:2559: riscv.o] Error 1
> 
> Suppress these warnings.
> 
> gcc/ChangeLog:
> 
> 	* config/riscv/riscv.cc (riscv_init_cumulative_args): Suppress warning.
> 	(riscv_vector_mode_supported_any_target_p): Ditto.
There's actually more cleanup to do in there ;-) One of the arguments 
currently marked as unused is actually used.  And the better way to 
handle unused arguments is to just drop their name (like you did with 
riscv_vector_mode_supported_any_target_p).

I'm actually in the process of bootstrapping and regression testing the 
additional fixes to riscv_init_cumulative_args.

jeff
钟居哲 Jan. 20, 2024, 1:18 a.m. UTC | #2
OK. I saw the other arguments there:

                            tree fntype ATTRIBUTE_UNUSED,
                            rtx libname ATTRIBUTE_UNUSED,

So I leverage these and add ATTRIBUTE_UNUSED to 'fndecl'

Maybe it's better remove all arguments for riscv_init_cumulative_args which are unused as you suggested.



juzhe.zhong@rivai.ai
 
From: Jeff Law
Date: 2024-01-20 08:52
To: Juzhe-Zhong; gcc-patches
CC: pan2.li; schwab
Subject: Re: [Committed] RISC-V: Suppress warning
 
 
On 1/19/24 17:27, Juzhe-Zhong wrote:
> ../../gcc/config/riscv/riscv.cc: In function 'void riscv_init_cumulative_args(CUMULATIVE_ARGS*, tree, rtx, tree, int)':
> ../../gcc/config/riscv/riscv.cc:4879:34: error: unused parameter 'fndecl' [-Werror=unused-parameter]
> 4879 |                             tree fndecl,
>        |                             ~~~~~^~~~~~
> ../../gcc/config/riscv/riscv.cc: In function 'bool riscv_vector_mode_supported_any_target_p(machine_mode)':
> ../../gcc/config/riscv/riscv.cc:10537:56: error: unused parameter 'mode' [-Werror=unused-parameter]
> 10537 | riscv_vector_mode_supported_any_target_p (machine_mode mode)
>        |                                           ~~~~~~~~~~~~~^~~~
> cc1plus: all warnings being treated as errors
> make[3]: *** [Makefile:2559: riscv.o] Error 1
> 
> Suppress these warnings.
> 
> gcc/ChangeLog:
> 
> * config/riscv/riscv.cc (riscv_init_cumulative_args): Suppress warning.
> (riscv_vector_mode_supported_any_target_p): Ditto.
There's actually more cleanup to do in there ;-) One of the arguments 
currently marked as unused is actually used.  And the better way to 
handle unused arguments is to just drop their name (like you did with 
riscv_vector_mode_supported_any_target_p).
 
I'm actually in the process of bootstrapping and regression testing the 
additional fixes to riscv_init_cumulative_args.
 
jeff
Jeff Law Jan. 21, 2024, 10:51 p.m. UTC | #3
On 1/19/24 18:18, 钟居哲 wrote:
> OK. I saw the other arguments there:
> 
>                              tree fntype ATTRIBUTE_UNUSED,
>                              rtx libname ATTRIBUTE_UNUSED,
> 
> So I leverage these and add ATTRIBUTE_UNUSED to 'fndecl'
> 
> Maybe it's better remove all arguments for riscv_init_cumulative_args 
> which are unused as you suggested.
Yea.  The biggest problem with ATTRIBUTE_UNUSED is that it's a "may be 
unused" and thus if the code changes it's sometimes left on an parameter 
incorrectly.  C++ allows us to specify a "is definitely unused" concept 
by dropping the parameter's name, but leaving its type.

I just pushed the obvious patch to fixup that function signature.  It 
would be a nice easy task for someone to go through all of riscv*.cc and 
clean those up after gcc-14 branches.

jeff
Andreas Schwab Jan. 21, 2024, 11:29 p.m. UTC | #4
On Jan 21 2024, Jeff Law wrote:

> Yea.  The biggest problem with ATTRIBUTE_UNUSED is that it's a "may be
> unused" and thus if the code changes it's sometimes left on an parameter
> incorrectly.  C++ allows us to specify a "is definitely unused" concept by
> dropping the parameter's name, but leaving its type.

It's problematic if the parameter is only used conditionally on a macro
definition (which is less common with target hooks now being function
calls).
diff mbox series

Patch

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index dd6e68a08c2..1f9546f4d3e 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -4876,7 +4876,7 @@  void
 riscv_init_cumulative_args (CUMULATIVE_ARGS *cum,
 			    tree fntype ATTRIBUTE_UNUSED,
 			    rtx libname ATTRIBUTE_UNUSED,
-			    tree fndecl,
+			    tree fndecl ATTRIBUTE_UNUSED,
 			    int caller ATTRIBUTE_UNUSED)
 {
   memset (cum, 0, sizeof (*cum));
@@ -10534,7 +10534,7 @@  extract_base_offset_in_addr (rtx mem, rtx *base, rtx *offset)
 /* Implements target hook vector_mode_supported_any_target_p.  */
 
 static bool
-riscv_vector_mode_supported_any_target_p (machine_mode mode)
+riscv_vector_mode_supported_any_target_p (machine_mode)
 {
   if (TARGET_XTHEADVECTOR)
     return false;