This was supposed to also be removed by
c48dadc9a8 ('x86: drop "mem"
operand type attribute'). It's odd enough that this hasn't caused
build issues, considering the careful use of OTunused (apparently to
avoid "missing initializer" warnings).
To avoid such happening again introduce compile time consistency
checks.
+2019-07-17 Jan Beulich <jbeulich@suse.com>
+
+ * i386-gen.c (static_assert): Define.
+ (main): Use it.
+ * i386-opc.h (Opcode_Modifier_Max): Rename to ...
+ (Opcode_Modifier_Num): ... this.
+ (Mem): Delete.
+
2019-07-16 Jan Beulich <jbeulich@suse.com>
* i386-gen.c (operand_types): Move RegMem ...
2019-07-16 Jan Beulich <jbeulich@suse.com>
* i386-gen.c (operand_types): Move RegMem ...
#include <libintl.h>
#define _(String) gettext (String)
#include <libintl.h>
#define _(String) gettext (String)
+/* Build-time checks are preferrable over runtime ones. Use this construct
+ in preference where possible. */
+#define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); }))
+
static const char *program_name = NULL;
static int debug = 0;
static const char *program_name = NULL;
static int debug = 0;
/* Check the unused bitfield in i386_cpu_flags. */
#ifdef CpuUnused
/* Check the unused bitfield in i386_cpu_flags. */
#ifdef CpuUnused
+ static_assert (ARRAY_SIZE (cpu_flags) == CpuMax + 2);
+
if ((cpumax - 1) != CpuMax)
fail (_("CpuMax != %d!\n"), cpumax);
#else
if ((cpumax - 1) != CpuMax)
fail (_("CpuMax != %d!\n"), cpumax);
#else
+ static_assert (ARRAY_SIZE (cpu_flags) == CpuMax + 1);
+
if (cpumax != CpuMax)
fail (_("CpuMax != %d!\n"), cpumax);
if (cpumax != CpuMax)
fail (_("CpuMax != %d!\n"), cpumax);
fail (_("%d unused bits in i386_cpu_flags.\n"), c);
#endif
fail (_("%d unused bits in i386_cpu_flags.\n"), c);
#endif
+ static_assert (ARRAY_SIZE (opcode_modifiers) == Opcode_Modifier_Num);
+
/* Check the unused bitfield in i386_operand_type. */
/* Check the unused bitfield in i386_operand_type. */
+#ifdef OTUnused
+ static_assert (ARRAY_SIZE (operand_types) == OTNum + 1);
+#else
+ static_assert (ARRAY_SIZE (operand_types) == OTNum);
+
c = OTNumOfBits - OTMax - 1;
if (c)
fail (_("%d unused bits in i386_operand_type.\n"), c);
c = OTNumOfBits - OTMax - 1;
if (c)
fail (_("%d unused bits in i386_operand_type.\n"), c);
/* Intel64. */
Intel64,
/* The last bitfield in i386_opcode_modifier. */
/* Intel64. */
Intel64,
/* The last bitfield in i386_opcode_modifier. */
};
typedef struct i386_opcode_modifier
};
typedef struct i386_opcode_modifier
JumpAbsolute,
/* String insn operand with fixed es segment */
EsSeg,
JumpAbsolute,
/* String insn operand with fixed es segment */
EsSeg,
/* BYTE size. */
Byte,
/* WORD size. 2 byte */
/* BYTE size. */
Byte,
/* WORD size. 2 byte */