[1/2] sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition

Message ID 20210620013532.578626-1-simon.marchi@polymtl.ca
State New
Headers show
Series
  • [1/2] sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition
Related show

Commit Message

Rustam Kovhaev via Gdb-patches June 20, 2021, 1:35 a.m.
I get this when building with gcc 11:

      CC       common/common_libcommon_a-sim-load.o
    In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,
                     from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,
                     from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: ‘offset_16’ defined but not used [-Werror=unused-function]
       39 | #define offset_N XCONCAT2(offset_,N)
          |                           ^~~~~~~
    /home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro ‘CONCAT2’
       23 | #define CONCAT2(a,b)     a##b
          |                          ^
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro ‘XCONCAT2’
       39 | #define offset_N XCONCAT2(offset_,N)
          |                  ^~~~~~~~
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro ‘offset_N’
      138 | offset_N (unsigned_N *x,
          | ^~~~~~~~

offset_N uses INLINE_SIM_ENDIAN, which uses UNUSED to put the "unused"
attribute.  However, it appears after the function's return type, which
seems to make it not apply to the function.  Moving it to before the
return type fixes the error.

sim/common/ChangeLog:

	* sim-inline.h (SIM_ENDIAN_INLINE): Move UNUSED before TYPE.

Change-Id: Ide20106683ed7a9ebf35d484dabf70b309cb1ba6
---
 sim/common/sim-inline.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.32.0

Comments

Rustam Kovhaev via Gdb-patches June 20, 2021, 2:07 a.m. | #1
On 19 Jun 2021 21:35, Simon Marchi via Gdb-patches wrote:
> I get this when building with gcc 11:

> 

>       CC       common/common_libcommon_a-sim-load.o

>     In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,

>                      from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,

>                      from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,

>                      from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,

>                      from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:

>     /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: ‘offset_16’ defined but not used [-Werror=unused-function]

>        39 | #define offset_N XCONCAT2(offset_,N)

>           |                           ^~~~~~~

>     /home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro ‘CONCAT2’

>        23 | #define CONCAT2(a,b)     a##b

>           |                          ^

>     /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro ‘XCONCAT2’

>        39 | #define offset_N XCONCAT2(offset_,N)

>           |                  ^~~~~~~~

>     /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro ‘offset_N’

>       138 | offset_N (unsigned_N *x,

>           | ^~~~~~~~

> 

> offset_N uses INLINE_SIM_ENDIAN, which uses UNUSED to put the "unused"

> attribute.  However, it appears after the function's return type, which

> seems to make it not apply to the function.  Moving it to before the

> return type fixes the error.


idea looks fine, but i'm pretty sure we want to s/TYPE UNUSED/UNUSED TYPE/
on this whole file, not this one macro.
-mike
Rustam Kovhaev via Gdb-patches June 20, 2021, 2:21 a.m. | #2
On 2021-06-19 10:07 p.m., Mike Frysinger wrote:
> On 19 Jun 2021 21:35, Simon Marchi via Gdb-patches wrote:

>> I get this when building with gcc 11:

>>

>>       CC       common/common_libcommon_a-sim-load.o

>>     In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,

>>                      from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,

>>                      from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,

>>                      from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,

>>                      from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:

>>     /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: ‘offset_16’ defined but not used [-Werror=unused-function]

>>        39 | #define offset_N XCONCAT2(offset_,N)

>>           |                           ^~~~~~~

>>     /home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro ‘CONCAT2’

>>        23 | #define CONCAT2(a,b)     a##b

>>           |                          ^

>>     /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro ‘XCONCAT2’

>>        39 | #define offset_N XCONCAT2(offset_,N)

>>           |                  ^~~~~~~~

>>     /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro ‘offset_N’

>>       138 | offset_N (unsigned_N *x,

>>           | ^~~~~~~~

>>

>> offset_N uses INLINE_SIM_ENDIAN, which uses UNUSED to put the "unused"

>> attribute.  However, it appears after the function's return type, which

>> seems to make it not apply to the function.  Moving it to before the

>> return type fixes the error.

> 

> idea looks fine, but i'm pretty sure we want to s/TYPE UNUSED/UNUSED TYPE/

> on this whole file, not this one macro.

> -mike

> 


Hmm yeah good idea.  Here's the updated patch:

From 1215077fa136c9cf44c2f933ba9d5de2465892d3 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>

Date: Sat, 19 Jun 2021 21:35:31 -0400
Subject: [PATCH] sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's
 definition
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

I get this when building with gcc 11:

      CC       common/common_libcommon_a-sim-load.o
    In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,
                     from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,
                     from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: ‘offset_16’ defined but not used [-Werror=unused-function]
       39 | #define offset_N XCONCAT2(offset_,N)
          |                           ^~~~~~~
    /home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro ‘CONCAT2’
       23 | #define CONCAT2(a,b)     a##b
          |                          ^
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro ‘XCONCAT2’
       39 | #define offset_N XCONCAT2(offset_,N)
          |                  ^~~~~~~~
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro ‘offset_N’
      138 | offset_N (unsigned_N *x,
          | ^~~~~~~~

offset_N uses INLINE_SIM_ENDIAN, which uses UNUSED to put the "unused"
attribute.  However, it appears after the function's return type, which
seems to make it not apply to the function.  Moving it to before the
return type fixes the error.

Change all instances found in that file.

sim/common/ChangeLog:

	* sim-inline.h (SIM_ENDIAN_INLINE): Move UNUSED before TYPE.

Change-Id: Ide20106683ed7a9ebf35d484dabf70b309cb1ba6
---
 sim/common/sim-inline.h | 54 ++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/sim/common/sim-inline.h b/sim/common/sim-inline.h
index 2750fa93cbc7..a397e58e10f2 100644
--- a/sim/common/sim-inline.h
+++ b/sim/common/sim-inline.h
@@ -345,10 +345,10 @@
      && !defined (SIM_ARANGE_C) \
      && (REVEAL_MODULE_P (SIM_ARANGE_INLINE)))
 # if (SIM_ARANGE_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_ARANGE(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_ARANGE(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SIM_ARANGE_P 0
 # else
-#  define INLINE_SIM_ARANGE(TYPE) static TYPE UNUSED
+#  define INLINE_SIM_ARANGE(TYPE) static UNUSED TYPE
 #  define EXTERN_SIM_ARANGE_P 0
 # endif
 #else
@@ -383,10 +383,10 @@
      && !defined (SIM_BITS_C) \
      && (REVEAL_MODULE_P (SIM_BITS_INLINE)))
 # if (SIM_BITS_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_BITS(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_BITS(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SIM_BITS_P 0
 # else
-#  define INLINE_SIM_BITS(TYPE) static TYPE UNUSED
+#  define INLINE_SIM_BITS(TYPE) static UNUSED TYPE
 #  define EXTERN_SIM_BITS_P 0
 # endif
 #else
@@ -414,10 +414,10 @@
      && !defined (SIM_CORE_C) \
      && (REVEAL_MODULE_P (SIM_CORE_INLINE)))
 # if (SIM_CORE_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_CORE(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_CORE(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SIM_CORE_P 0
 #else
-#  define INLINE_SIM_CORE(TYPE) static TYPE UNUSED
+#  define INLINE_SIM_CORE(TYPE) static UNUSED TYPE
 #  define EXTERN_SIM_CORE_P 0
 #endif
 #else
@@ -445,10 +445,10 @@
      && !defined (SIM_ENDIAN_C) \
      && (REVEAL_MODULE_P (SIM_ENDIAN_INLINE)))
 # if (SIM_ENDIAN_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_ENDIAN(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SIM_ENDIAN_P 0
 # else
-#  define INLINE_SIM_ENDIAN(TYPE) static TYPE UNUSED
+#  define INLINE_SIM_ENDIAN(TYPE) static UNUSED TYPE
 #  define EXTERN_SIM_ENDIAN_P 0
 # endif
 #else
@@ -476,10 +476,10 @@
      && !defined (SIM_EVENTS_C) \
      && (REVEAL_MODULE_P (SIM_EVENTS_INLINE)))
 # if (SIM_EVENTS_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_EVENTS(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_EVENTS(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SIM_EVENTS_P 0
 # else
-#  define INLINE_SIM_EVENTS(TYPE) static TYPE UNUSED
+#  define INLINE_SIM_EVENTS(TYPE) static UNUSED TYPE
 #  define EXTERN_SIM_EVENTS_P 0
 # endif
 #else
@@ -507,10 +507,10 @@
      && !defined (SIM_FPU_C) \
      && (REVEAL_MODULE_P (SIM_FPU_INLINE)))
 # if (SIM_FPU_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_FPU(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_FPU(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SIM_FPU_P 0
 # else
-#  define INLINE_SIM_FPU(TYPE) static TYPE UNUSED
+#  define INLINE_SIM_FPU(TYPE) static UNUSED TYPE
 #  define EXTERN_SIM_FPU_P 0
 # endif
 #else
@@ -534,10 +534,10 @@
      && !defined (SIM_TYPES_C) \
      && (REVEAL_MODULE_P (SIM_TYPES_INLINE)))
 # if (SIM_TYPES_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_TYPES(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_TYPES(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SIM_TYPES_P 0
 # else
-#  define INLINE_SIM_TYPES(TYPE) static TYPE UNUSED
+#  define INLINE_SIM_TYPES(TYPE) static UNUSED TYPE
 #  define EXTERN_SIM_TYPES_P 0
 # endif
 #else
@@ -565,10 +565,10 @@
      && !defined (SIM_MAIN_C) \
      && (REVEAL_MODULE_P (SIM_MAIN_INLINE)))
 # if (SIM_MAIN_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_MAIN(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_MAIN(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SIM_MAIN_P 0
 # else
-#  define INLINE_SIM_MAIN(TYPE) static TYPE UNUSED
+#  define INLINE_SIM_MAIN(TYPE) static UNUSED TYPE
 #  define EXTERN_SIM_MAIN_P 0
 # endif
 #else
@@ -590,10 +590,10 @@
      && !defined (ENGINE_C) \
      && (REVEAL_MODULE_P (ENGINE_INLINE)))
 # if (ENGINE_INLINE & INLINE_GLOBALS)
-#  define INLINE_ENGINE(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_ENGINE(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_ENGINE_P 0
 # else
-#  define INLINE_ENGINE(TYPE) static TYPE UNUSED
+#  define INLINE_ENGINE(TYPE) static UNUSED TYPE
 #  define EXTERN_ENGINE_P 0
 # endif
 #else
@@ -617,10 +617,10 @@
      && !defined (ICACHE_C) \
      && (REVEAL_MODULE_P (ICACHE_INLINE)))
 # if (ICACHE_INLINE & INLINE_GLOBALS)
-#  define INLINE_ICACHE(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_ICACHE(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_ICACHE_P 0
 #else
-#  define INLINE_ICACHE(TYPE) static TYPE UNUSED
+#  define INLINE_ICACHE(TYPE) static UNUSED TYPE
 #  define EXTERN_ICACHE_P 0
 #endif
 #else
@@ -644,10 +644,10 @@
      && !defined (IDECODE_C) \
      && (REVEAL_MODULE_P (IDECODE_INLINE)))
 # if (IDECODE_INLINE & INLINE_GLOBALS)
-#  define INLINE_IDECODE(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_IDECODE(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_IDECODE_P 0
 #else
-#  define INLINE_IDECODE(TYPE) static TYPE UNUSED
+#  define INLINE_IDECODE(TYPE) static UNUSED TYPE
 #  define EXTERN_IDECODE_P 0
 #endif
 #else
@@ -671,10 +671,10 @@
      && !defined (SEMANTICS_C) \
      && (REVEAL_MODULE_P (SEMANTICS_INLINE)))
 # if (SEMANTICS_INLINE & INLINE_GLOBALS)
-#  define INLINE_SEMANTICS(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SEMANTICS(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SEMANTICS_P 0
 #else
-#  define INLINE_SEMANTICS(TYPE) static TYPE UNUSED
+#  define INLINE_SEMANTICS(TYPE) static UNUSED TYPE
 #  define EXTERN_SEMANTICS_P 0
 #endif
 #else
@@ -685,7 +685,7 @@
 #if EXTERN_SEMANTICS_P
 # define EXTERN_SEMANTICS(TYPE) TYPE
 #else
-# define EXTERN_SEMANTICS(TYPE) static TYPE UNUSED
+# define EXTERN_SEMANTICS(TYPE) static UNUSED TYPE
 #endif
 
 #if (SEMANTICS_INLINE & INLINE_LOCALS)
@@ -708,10 +708,10 @@
      && !defined (SUPPORT_C) \
      && (REVEAL_MODULE_P (SUPPORT_INLINE)))
 # if (SUPPORT_INLINE & INLINE_GLOBALS)
-#  define INLINE_SUPPORT(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SUPPORT(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SUPPORT_P 0
 #else
-#  define INLINE_SUPPORT(TYPE) static TYPE UNUSED
+#  define INLINE_SUPPORT(TYPE) static UNUSED TYPE
 #  define EXTERN_SUPPORT_P 0
 #endif
 #else
-- 
2.32.0
Rustam Kovhaev via Gdb-patches June 20, 2021, 2:47 a.m. | #3
On 19 Jun 2021 22:21, Simon Marchi via Gdb-patches wrote:
> Hmm yeah good idea.  Here's the updated patch:


lgtm, thanks
-mike
Rustam Kovhaev via Gdb-patches June 20, 2021, 2:50 a.m. | #4
On 2021-06-19 10:47 p.m., Mike Frysinger wrote:
> On 19 Jun 2021 22:21, Simon Marchi via Gdb-patches wrote:

>> Hmm yeah good idea.  Here's the updated patch:

> 

> lgtm, thanks

> -mike

> 


Pushed, thanks.

Simon

Patch

diff --git a/sim/common/sim-inline.h b/sim/common/sim-inline.h
index 2750fa93cbc7..6ac4942e3521 100644
--- a/sim/common/sim-inline.h
+++ b/sim/common/sim-inline.h
@@ -445,7 +445,7 @@ 
      && !defined (SIM_ENDIAN_C) \
      && (REVEAL_MODULE_P (SIM_ENDIAN_INLINE)))
 # if (SIM_ENDIAN_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_ENDIAN(TYPE) static INLINE UNUSED TYPE
 #  define EXTERN_SIM_ENDIAN_P 0
 # else
 #  define INLINE_SIM_ENDIAN(TYPE) static TYPE UNUSED