aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2021-05-21 17:26:24 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2021-05-21 17:27:05 -0700
commit39549caef4ae5e5adb5a52518d195f367315e9e9 (patch)
treecaa49cda7cb4a7f544a3d4dabb0d53eaf7ab3ed3
parent33d93379d258dfb2bebdd67e32e00c9667c486e2 (diff)
downloadgdb-39549caef4ae5e5adb5a52518d195f367315e9e9.zip
gdb-39549caef4ae5e5adb5a52518d195f367315e9e9.tar.gz
gdb-39549caef4ae5e5adb5a52518d195f367315e9e9.tar.bz2
sim/d10v: Use offsetof in a static assertion about structure layout.
clang 11 fails to compile the static assertion as it cannot compute the pointer value at a compile time: gdb/sim/d10v/interp.c:1149:37: error: static_assert expression is not an integral constant expression static_assert ((uintptr_t) &State == (uintptr_t) &State.regs, ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Instead, assert that the offset of State.regs is 0. sim/d10v/ChangeLog: * interp.c (sim_create_inferior): Use offsetof in static assertion.
-rw-r--r--sim/d10v/ChangeLog5
-rw-r--r--sim/d10v/interp.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/sim/d10v/ChangeLog b/sim/d10v/ChangeLog
index e45bd38..e633352 100644
--- a/sim/d10v/ChangeLog
+++ b/sim/d10v/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-22 John Baldwin <jhb@FreeBSD.org>
+
+ * interp.c (sim_create_inferior): Use offsetof in static
+ assertion.
+
2021-05-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (SIM_HAVE_COMMON_SIM_STATE): Delete.
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index b56b204..b587cc1 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -1146,8 +1146,8 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
bfd_vma start_address;
/* Make sure we have the right structure for the following memset. */
- static_assert ((uintptr_t) &State == (uintptr_t) &State.regs,
- "&State != &State.regs");
+ static_assert (offsetof (struct _state, regs) == 0,
+ "State.regs is not at offset 0");
/* Reset state from the regs field until the mem field. */
memset (&State, 0, (uintptr_t) &State.mem - (uintptr_t) &State.regs);