]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
opcodes: fix -std=gnu23 compatibility wrt static_assert
authorSam James <sam@gentoo.org>
Sat, 16 Nov 2024 05:03:52 +0000 (05:03 +0000)
committerSam James <sam@gentoo.org>
Mon, 18 Nov 2024 03:09:15 +0000 (03:09 +0000)
static_assert is declared in C23 so we can't reuse that identifier:
* Define our own static_assert conditionally;

* Rename "static assert" hacks to _N as we do already in some places
  to avoid a conflict.

ChangeLog:
PR ld/32372

        * i386-gen.c (static_assert): Define conditionally.
        * mips-formats.h (MAPPED_INT): Rename identifier.
        (MAPPED_REG): Rename identifier.
        (OPTIONAL_MAPPED_REG): Rename identifier.
        * s390-opc.c (static_assert): Define conditionally.

opcodes/i386-gen.c
opcodes/mips-formats.h
opcodes/s390-opc.c

index 053b66675c5ad194b4db7752e796d573e3a8a758..7ee8a30310cfc601bd6977a43aee1a6f25e4e216 100644 (file)
@@ -30,7 +30,9 @@
 
 /* Build-time checks are preferrable over runtime ones.  Use this construct
    in preference where possible.  */
+#ifndef static_assert
 #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); }))
+#endif
 
 static const char *program_name = NULL;
 static int debug = 0;
index 90df71008033200ce662b8673b6ff0cb1cadde43..c4dec6352bf30e610dfa4262a48d1e912413b291 100644 (file)
@@ -49,7 +49,7 @@
 #define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \
   { \
     typedef char ATTRIBUTE_UNUSED \
-      static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
+      static_assert_3[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
     static const struct mips_mapped_int_operand op = { \
       { OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \
     }; \
@@ -83,7 +83,7 @@
 #define MAPPED_REG(SIZE, LSB, BANK, MAP) \
   { \
     typedef char ATTRIBUTE_UNUSED \
-      static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
+      static_assert_4[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
     static const struct mips_reg_operand op = { \
       { OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
     }; \
@@ -93,7 +93,7 @@
 #define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \
   { \
     typedef char ATTRIBUTE_UNUSED \
-      static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
+      static_assert_5[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
     static const struct mips_reg_operand op = { \
       { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
     }; \
index 9d9f0973e55a8c2437323a64b28dd420f78eeb01..49efd714157d96f507c1821e3acab1ce84b703ba 100644 (file)
@@ -36,7 +36,9 @@
 
 /* Build-time checks are preferrable over runtime ones.  Use this construct
    in preference where possible.  */
+#ifndef static_assert
 #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); }))
+#endif
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))