public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition
Date: Sat, 19 Jun 2021 22:21:32 -0400	[thread overview]
Message-ID: <3c289851-e9e9-9f67-04db-339ec97236e7@polymtl.ca> (raw)
In-Reply-To: <YM6i0IXMRMpwyASs@vapier>



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


  reply	other threads:[~2021-06-20  2:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-20  1:35 Simon Marchi
2021-06-20  1:35 ` [PATCH 2/2] sim: use INLINE2 in STATIC_INLINE's definition Simon Marchi
2021-06-20  2:07 ` [PATCH 1/2] sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition Mike Frysinger
2021-06-20  2:21   ` Simon Marchi [this message]
2021-06-20  2:47     ` Mike Frysinger
2021-06-20  2:50       ` Simon Marchi

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=3c289851-e9e9-9f67-04db-339ec97236e7@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.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: link
Be 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).