]> git.ipfire.org Git - thirdparty/openwrt.git/blob
3364e9ae04cf53106080c1f328edeb9623ea80ae
[thirdparty/openwrt.git] /
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
5
6 static_assert is declared in C23 so we can't reuse that identifier:
7 * Define our own static_assert conditionally;
8
9 * Rename "static assert" hacks to _N as we do already in some places
10 to avoid a conflict.
11
12 ChangeLog:
13 PR ld/32372
14
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.
20 ---
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(-)
25
26 --- a/opcodes/i386-gen.c
27 +++ b/opcodes/i386-gen.c
28 @@ -33,7 +33,9 @@
29
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); }))
34 +#endif
35
36 static const char *program_name = NULL;
37 static int debug = 0;
38 --- a/opcodes/mips-formats.h
39 +++ b/opcodes/mips-formats.h
40 @@ -49,7 +49,7 @@
41 #define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \
42 { \
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 \
48 }; \
49 @@ -83,7 +83,7 @@
50 #define MAPPED_REG(SIZE, LSB, BANK, MAP) \
51 { \
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 \
57 }; \
58 @@ -93,7 +93,7 @@
59 #define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \
60 { \
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 \
66 }; \