1 From 8ebe62f3f0d27806b1bf69f301f5e188b4acd2b4 Mon Sep 17 00:00:00 2001
2 From: Sam James <sam@gentoo.org>
3 Date: Sat, 16 Nov 2024 05:03:52 +0000
4 Subject: [PATCH] opcodes: fix -std=gnu23 compatibility wrt static_assert
6 static_assert is declared in C23 so we can't reuse that identifier:
7 * Define our own static_assert conditionally;
9 * Rename "static assert" hacks to _N as we do already in some places
15 * i386-gen.c (static_assert): Define conditionally.
16 * mips-formats.h (MAPPED_INT): Rename identifier.
17 (MAPPED_REG): Rename identifier.
18 (OPTIONAL_MAPPED_REG): Rename identifier.
19 * s390-opc.c (static_assert): Define conditionally.
21 opcodes/i386-gen.c | 2 ++
22 opcodes/mips-formats.h | 6 +++---
23 opcodes/s390-opc.c | 2 ++
24 3 files changed, 7 insertions(+), 3 deletions(-)
26 --- a/opcodes/i386-gen.c
27 +++ b/opcodes/i386-gen.c
30 /* Build-time checks are preferrable over runtime ones. Use this construct
31 in preference where possible. */
32 +#ifndef static_assert
33 #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); }))
36 static const char *program_name = NULL;
38 --- a/opcodes/mips-formats.h
39 +++ b/opcodes/mips-formats.h
41 #define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \
43 typedef char ATTRIBUTE_UNUSED \
44 - static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
45 + static_assert_3[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
46 static const struct mips_mapped_int_operand op = { \
47 { OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \
50 #define MAPPED_REG(SIZE, LSB, BANK, MAP) \
52 typedef char ATTRIBUTE_UNUSED \
53 - static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
54 + static_assert_4[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
55 static const struct mips_reg_operand op = { \
56 { OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
59 #define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \
61 typedef char ATTRIBUTE_UNUSED \
62 - static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
63 + static_assert_5[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
64 static const struct mips_reg_operand op = { \
65 { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, MAP \