Re: [PATCH/committed 2/2] sim: mn10300: enable -Werror

Simon Marchi via Gdb-patches
2021-06-16T15:47:41Z

On 2021-06-16 11:35 a.m., Simon Marchi via Gdb-patches wrote:
> On 2021-06-14 11:47 p.m., Mike Frysinger via Gdb-patches wrote:
>> Now that all warnings are fixed in this port, enable -Werror by default.
>
> Hi Mike,
>
> I get:
>
> $ gcc --version
> gcc (GCC) 11.1.0
> $ ccache gcc -DHAVE_CONFIG_H -DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31 -DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE -DWITH_HW=1 -DHAVE_DV_SOCKSER -DDEFAULT_INLINE=0 -DWITH_RESERVED_BITS=1 -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type -Wold-style-declaration -Werror -I. -I/home/simark/src/binutils-gdb/sim/mn10300 -I../common -I/home/simark/src/binutils-gdb/sim/mn10300/../common -I../../include -I/home/simark/src/binutils-gdb/sim/mn10300/../../include -I../../bfd -I/home/simark/src/binutils-gdb/sim/mn10300/../../bfd -I../../opcodes -I/home/simark/src/binutils-gdb/sim/mn10300/../../opcodes -I../.. -I/home/simark/src/binutils-gdb/sim/mn10300/../../gnulib/import -I../../gnulib/import -DPOLL_QUIT_INTERVAL=0x20 -g3 -O0 -fsanitize=address -fmax-errors=1 -fdiagnostics-color=always -c -o idecode.o -MT idecode.o -MMD -MP -MF .deps/idecode.Tpo idecode.c
> In file included from /home/simark/src/binutils-gdb/sim/mn10300/sim-main.h:47,
> from /home/simark/src/binutils-gdb/sim/mn10300/../common/sim-inline.c:33,
> from idecode.c:26:
> /home/simark/src/binutils-gdb/sim/mn10300/mn10300_sim.h:189:1: error: ‘dw2u64’ defined but not used [-Werror=unused-function]
> 189 | dw2u64 (dword data)
> | ^~~~~~
>
> Simon
>

This fixes it for me, I guess that INLINE is undefined at this point.
I don't see any reason not to use "inline".

diff --git a/sim/mn10300/mn10300_sim.h b/sim/mn10300/mn10300_sim.h
index c63efaa6c769..b2ed70ecfe1d 100644
--- a/sim/mn10300/mn10300_sim.h
+++ b/sim/mn10300/mn10300_sim.h
@@ -158,7 +158,7 @@ sim_core_read_unaligned_4 (STATE_CPU (simulator, 0), PC, read_map, (ADDR))
u642dw (sim_core_read_unaligned_8 (STATE_CPU (simulator, 0), \
PC, read_map, (ADDR)))

-static INLINE dword
+static inline dword
u642dw (unsigned64 dw)
{
dword r;
@@ -185,7 +185,7 @@ sim_core_write_unaligned_4 (STATE_CPU (simulator, 0), \
sim_core_write_unaligned_8 (STATE_CPU (simulator, 0), \
PC, write_map, (ADDR), dw2u64 (DATA))

-static INLINE unsigned64
+static inline unsigned64
dw2u64 (dword data)
{
return data.low | (((unsigned64)data.high) << 32);

Simon