Skip to content

Commit

Permalink
Remove gdb_static_assert
Browse files Browse the repository at this point in the history
C++17 makes the second parameter to static_assert optional, so we can
remove gdb_static_assert now.
  • Loading branch information
tromey committed Nov 29, 2023
1 parent d02f31b commit 69f6730
Show file tree
Hide file tree
Showing 50 changed files with 106 additions and 111 deletions.
8 changes: 4 additions & 4 deletions gdb/aarch64-linux-nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fetch_gregs_from_thread (struct regcache *regcache)

/* Make sure REGS can hold all registers contents on both aarch64
and arm. */
gdb_static_assert (sizeof (regs) >= 18 * 4);
static_assert (sizeof (regs) >= 18 * 4);

tid = regcache->ptid ().lwp ();

Expand Down Expand Up @@ -175,7 +175,7 @@ store_gregs_to_thread (const struct regcache *regcache)

/* Make sure REGS can hold all registers contents on both aarch64
and arm. */
gdb_static_assert (sizeof (regs) >= 18 * 4);
static_assert (sizeof (regs) >= 18 * 4);
tid = regcache->ptid ().lwp ();

iovec.iov_base = &regs;
Expand Down Expand Up @@ -217,7 +217,7 @@ fetch_fpregs_from_thread (struct regcache *regcache)

/* Make sure REGS can hold all VFP registers contents on both aarch64
and arm. */
gdb_static_assert (sizeof regs >= ARM_VFP3_REGS_SIZE);
static_assert (sizeof regs >= ARM_VFP3_REGS_SIZE);

tid = regcache->ptid ().lwp ();

Expand Down Expand Up @@ -264,7 +264,7 @@ store_fpregs_to_thread (const struct regcache *regcache)

/* Make sure REGS can hold all VFP registers contents on both aarch64
and arm. */
gdb_static_assert (sizeof regs >= ARM_VFP3_REGS_SIZE);
static_assert (sizeof regs >= ARM_VFP3_REGS_SIZE);
tid = regcache->ptid ().lwp ();

iovec.iov_base = &regs;
Expand Down
4 changes: 2 additions & 2 deletions gdb/aarch64-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -3113,7 +3113,7 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch,

/* Enough space for a full vector register. */
gdb_byte reg_buf[register_size (gdbarch, AARCH64_V0_REGNUM)];
gdb_static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);
static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);

if (regcache->raw_read (v_regnum, reg_buf) != REG_VALID)
result_value->mark_bytes_unavailable (0,
Expand Down Expand Up @@ -3323,7 +3323,7 @@ aarch64_pseudo_write_1 (struct gdbarch *gdbarch, struct regcache *regcache,

/* Enough space for a full vector register. */
gdb_byte reg_buf[register_size (gdbarch, AARCH64_V0_REGNUM)];
gdb_static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);
static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);

/* Ensure the register buffer is zero, we want gdb writes of the
various 'scalar' pseudo registers to behavior like architectural
Expand Down
4 changes: 2 additions & 2 deletions gdb/addrmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

/* Make sure splay trees can actually hold the values we want to
store in them. */
gdb_static_assert (sizeof (splay_tree_key) >= sizeof (CORE_ADDR *));
gdb_static_assert (sizeof (splay_tree_value) >= sizeof (void *));
static_assert (sizeof (splay_tree_key) >= sizeof (CORE_ADDR *));
static_assert (sizeof (splay_tree_value) >= sizeof (void *));


/* Fixed address maps. */
Expand Down
2 changes: 1 addition & 1 deletion gdb/alpha-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ alpha_register_name (struct gdbarch *gdbarch, int regno)
"pc", "", "unique"
};

gdb_static_assert (ALPHA_NUM_REGS == ARRAY_SIZE (register_names));
static_assert (ALPHA_NUM_REGS == ARRAY_SIZE (register_names));
return register_names[regno];
}

Expand Down
4 changes: 2 additions & 2 deletions gdb/arc-linux-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ arc_linux_supply_gregset (const struct regset *regset,
struct regcache *regcache,
int regnum, const void *gregs, size_t size)
{
gdb_static_assert (ARC_LAST_REGNUM
static_assert (ARC_LAST_REGNUM
< ARRAY_SIZE (arc_linux_core_reg_offsets));

const bfd_byte *buf = (const bfd_byte *) gregs;
Expand Down Expand Up @@ -612,7 +612,7 @@ arc_linux_collect_gregset (const struct regset *regset,
const struct regcache *regcache,
int regnum, void *gregs, size_t size)
{
gdb_static_assert (ARC_LAST_REGNUM
static_assert (ARC_LAST_REGNUM
< ARRAY_SIZE (arc_linux_core_reg_offsets));

gdb_byte *buf = (gdb_byte *) gregs;
Expand Down
2 changes: 1 addition & 1 deletion gdb/arc-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ arc_insn_get_operand_value_signed (const struct arc_instruction &insn,
/* Convert unsigned raw value to signed one. This assumes 2's
complement arithmetic, but so is the LONG_MIN value from generic
defs.h and that assumption is true for ARC. */
gdb_static_assert (sizeof (insn.limm_value) == sizeof (int));
static_assert (sizeof (insn.limm_value) == sizeof (int));
return (((LONGEST) insn.limm_value) ^ INT_MIN) - INT_MIN;
case ARC_OPERAND_KIND_SHIMM:
/* Sign conversion has been done by binutils. */
Expand Down
2 changes: 1 addition & 1 deletion gdb/avr-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ avr_register_name (struct gdbarch *gdbarch, int regnum)
"SREG", "SP", "PC2",
"pc"
};
gdb_static_assert (ARRAY_SIZE (register_names)
static_assert (ARRAY_SIZE (register_names)
== (AVR_NUM_REGS + AVR_NUM_PSEUDO_REGS));
return register_names[regnum];
}
Expand Down
2 changes: 1 addition & 1 deletion gdb/bpf-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static const char *bpf_register_names[] =
static const char *
bpf_register_name (struct gdbarch *gdbarch, int reg)
{
gdb_static_assert (ARRAY_SIZE (bpf_register_names) == BPF_NUM_REGS);
static_assert (ARRAY_SIZE (bpf_register_names) == BPF_NUM_REGS);
return bpf_register_names[reg];
}

Expand Down
2 changes: 1 addition & 1 deletion gdb/charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ default_auto_wide_charset (void)

/* GDB cannot handle strings correctly if this size is different. */

gdb_static_assert (sizeof (gdb_wchar_t) == 2 || sizeof (gdb_wchar_t) == 4);
static_assert (sizeof (gdb_wchar_t) == 2 || sizeof (gdb_wchar_t) == 4);

/* intermediate_encoding returns the charset used internally by
GDB to convert between target and host encodings. As the test above
Expand Down
4 changes: 2 additions & 2 deletions gdb/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ struct setting
/* Getters and setters are cast to and from the arbitrary `void (*) ()`
function pointer type. Make sure that the two types are really of the
same size. */
gdb_static_assert (sizeof (m_getter) == sizeof (getter));
gdb_static_assert (sizeof (m_setter) == sizeof (setter));
static_assert (sizeof (m_getter) == sizeof (getter));
static_assert (sizeof (m_setter) == sizeof (setter));

m_getter = reinterpret_cast<erased_func> (getter);
m_setter = reinterpret_cast<erased_func> (setter);
Expand Down
2 changes: 1 addition & 1 deletion gdb/cris-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,7 @@ cris_register_name (struct gdbarch *gdbarch, int regno)
if (regno < NUM_GENREGS)
{
/* General register. */
gdb_static_assert (ARRAY_SIZE (cris_genreg_names) == NUM_GENREGS);
static_assert (ARRAY_SIZE (cris_genreg_names) == NUM_GENREGS);
return cris_genreg_names[regno];
}
else if (regno >= NUM_GENREGS && regno < gdbarch_num_regs (gdbarch))
Expand Down
2 changes: 1 addition & 1 deletion gdb/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ enum language
/* The number of bits needed to represent all languages, with enough
padding to allow for reasonable growth. */
#define LANGUAGE_BITS 5
gdb_static_assert (nr_languages <= (1 << LANGUAGE_BITS));
static_assert (nr_languages <= (1 << LANGUAGE_BITS));

/* The number of bytes needed to represent all languages. */
#define LANGUAGE_BYTES ((LANGUAGE_BITS + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT)
Expand Down
2 changes: 1 addition & 1 deletion gdb/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ gdb_disassembler::print_insn (CORE_ADDR memaddr,
To do this we perform an in-place new, but this time turn on
the styling support, then we can re-disassembly the
instruction, and gain any minimal styling GDB might add. */
gdb_static_assert ((std::is_same<decltype (m_buffer),
static_assert ((std::is_same<decltype (m_buffer),
string_file>::value));
gdb_assert (!m_buffer.term_out ());
m_buffer.~string_file ();
Expand Down
4 changes: 2 additions & 2 deletions gdb/dwarf2/read-gdb-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ create_cus_from_gdb_index_list (dwarf2_per_bfd *per_bfd,
{
for (offset_type i = 0; i < n_elements; i += 2)
{
gdb_static_assert (sizeof (ULONGEST) >= 8);
static_assert (sizeof (ULONGEST) >= 8);

sect_offset sect_off
= (sect_offset) extract_unsigned_integer (cu_list, 8, BFD_ENDIAN_LITTLE);
Expand Down Expand Up @@ -700,7 +700,7 @@ create_signatured_type_table_from_gdb_index
void **slot;
cu_offset type_offset_in_tu;

gdb_static_assert (sizeof (ULONGEST) >= 8);
static_assert (sizeof (ULONGEST) >= 8);
sect_offset sect_off
= (sect_offset) extract_unsigned_integer (bytes, 8, BFD_ENDIAN_LITTLE);
type_offset_in_tu
Expand Down
2 changes: 1 addition & 1 deletion gdb/dwarf2/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -10287,7 +10287,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)

/* We never call the destructor of call_site, so we must ensure it is
trivially destructible. */
gdb_static_assert(std::is_trivially_destructible<struct call_site>::value);
static_assert(std::is_trivially_destructible<struct call_site>::value);

if (dwarf2_flag_true_p (die, DW_AT_call_tail_call, cu)
|| dwarf2_flag_true_p (die, DW_AT_GNU_tail_call, cu))
Expand Down
2 changes: 1 addition & 1 deletion gdb/f-array-walker.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class fortran_array_walker
/* Ensure that Impl is derived from the required base class. This just
ensures that all of the required API methods are available and have a
sensible default implementation. */
gdb_static_assert ((std::is_base_of<fortran_array_walker_base_impl,Impl>::value));
static_assert ((std::is_base_of<fortran_array_walker_base_impl,Impl>::value));

public:
/* Create a new array walker. TYPE is the type of the array being walked
Expand Down
2 changes: 1 addition & 1 deletion gdb/ft32-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static const char *const ft32_register_names[] =
static const char *
ft32_register_name (struct gdbarch *gdbarch, int reg_nr)
{
gdb_static_assert (ARRAY_SIZE (ft32_register_names) == FT32_NUM_REGS);
static_assert (ARRAY_SIZE (ft32_register_names) == FT32_NUM_REGS);
return ft32_register_names[reg_nr];
}

Expand Down
2 changes: 1 addition & 1 deletion gdb/gdb_bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ gdb_bfd_record_inclusion (bfd *includer, bfd *includee)



gdb_static_assert (ARRAY_SIZE (_bfd_std_section) == 4);
static_assert (ARRAY_SIZE (_bfd_std_section) == 4);

/* See gdb_bfd.h. */

Expand Down
4 changes: 2 additions & 2 deletions gdb/hppa-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ hppa32_register_name (struct gdbarch *gdbarch, int i)
"fr28", "fr28R", "fr29", "fr29R",
"fr30", "fr30R", "fr31", "fr31R"
};
gdb_static_assert (ARRAY_SIZE (names) == hppa32_num_regs);
static_assert (ARRAY_SIZE (names) == hppa32_num_regs);
return names[i];
}

Expand Down Expand Up @@ -665,7 +665,7 @@ hppa64_register_name (struct gdbarch *gdbarch, int i)
"fr24", "fr25", "fr26", "fr27",
"fr28", "fr29", "fr30", "fr31"
};
gdb_static_assert (ARRAY_SIZE (names) == hppa64_num_regs);
static_assert (ARRAY_SIZE (names) == hppa64_num_regs);
return names[i];
}

Expand Down
2 changes: 1 addition & 1 deletion gdb/iq2000-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ iq2000_register_name (struct gdbarch *gdbarch, int regnum)
"r30", "r31",
"pc"
};
gdb_static_assert (ARRAY_SIZE (names) == E_NUM_REGS);
static_assert (ARRAY_SIZE (names) == E_NUM_REGS);
return names[regnum];
}

Expand Down
2 changes: 1 addition & 1 deletion gdb/linux-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ linux_read_core_file_mappings
read_core_file_mappings_loop_ftype loop_cb)
{
/* Ensure that ULONGEST is big enough for reading 64-bit core files. */
gdb_static_assert (sizeof (ULONGEST) >= 8);
static_assert (sizeof (ULONGEST) >= 8);

/* It's not required that the NT_FILE note exists, so return silently
if it's not found. Beyond this point though, we'll complain
Expand Down
2 changes: 1 addition & 1 deletion gdb/lm32-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ lm32_register_name (struct gdbarch *gdbarch, int reg_nr)
"PC", "EID", "EBA", "DEBA", "IE", "IM", "IP"
};

gdb_static_assert (ARRAY_SIZE (register_names) == SIM_LM32_NUM_REGS);
static_assert (ARRAY_SIZE (register_names) == SIM_LM32_NUM_REGS);
return register_names[reg_nr];
}

Expand Down
2 changes: 1 addition & 1 deletion gdb/m32r-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static const char * const m32r_register_names[] = {
static const char *
m32r_register_name (struct gdbarch *gdbarch, int reg_nr)
{
gdb_static_assert (ARRAY_SIZE (m32r_register_names) == M32R_NUM_REGS);
static_assert (ARRAY_SIZE (m32r_register_names) == M32R_NUM_REGS);
return m32r_register_names[reg_nr];
}

Expand Down
2 changes: 1 addition & 1 deletion gdb/m68k-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ m68k_register_name (struct gdbarch *gdbarch, int regnum)
{
m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);

gdb_static_assert (ARRAY_SIZE (m68k_register_names) == M68K_NUM_REGS);
static_assert (ARRAY_SIZE (m68k_register_names) == M68K_NUM_REGS);
if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM
&& tdep->fpregs_present == 0)
return "";
Expand Down
2 changes: 1 addition & 1 deletion gdb/mi/mi-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static const char * const async_reason_string_lookup[] =
NULL
};

gdb_static_assert (ARRAY_SIZE (async_reason_string_lookup)
static_assert (ARRAY_SIZE (async_reason_string_lookup)
== EXEC_ASYNC_LAST + 1);

const char *
Expand Down
2 changes: 1 addition & 1 deletion gdb/microblaze-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static unsigned int microblaze_debug_flag = 0;
static const char *
microblaze_register_name (struct gdbarch *gdbarch, int regnum)
{
gdb_static_assert (ARRAY_SIZE (microblaze_register_names)
static_assert (ARRAY_SIZE (microblaze_register_names)
== MICROBLAZE_NUM_REGS);
return microblaze_register_names[regnum];
}
Expand Down
2 changes: 1 addition & 1 deletion gdb/moxie-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static const char * const moxie_register_names[] = {
static const char *
moxie_register_name (struct gdbarch *gdbarch, int reg_nr)
{
gdb_static_assert (ARRAY_SIZE (moxie_register_names) == MOXIE_NUM_REGS);
static_assert (ARRAY_SIZE (moxie_register_names) == MOXIE_NUM_REGS);
return moxie_register_names[reg_nr];
}

Expand Down
2 changes: 1 addition & 1 deletion gdb/msp430-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ msp430_register_name (struct gdbarch *gdbarch, int regnr)
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
};

gdb_static_assert (ARRAY_SIZE (reg_names) == (MSP430_NUM_REGS
static_assert (ARRAY_SIZE (reg_names) == (MSP430_NUM_REGS
+ MSP430_NUM_PSEUDO_REGS));
return reg_names[regnr];
}
Expand Down
10 changes: 5 additions & 5 deletions gdb/nat/amd64-linux-siginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,10 @@ amd64_linux_siginfo_fixup_common (siginfo_t *ptrace, gdb_byte *inf,

/* Sanity check for the siginfo structure sizes. */

gdb_static_assert (sizeof (siginfo_t) == GDB_SI_SIZE);
static_assert (sizeof (siginfo_t) == GDB_SI_SIZE);
#ifndef __ILP32__
gdb_static_assert (sizeof (nat_siginfo_t) == GDB_SI_SIZE);
static_assert (sizeof (nat_siginfo_t) == GDB_SI_SIZE);
#endif
gdb_static_assert (sizeof (compat_x32_siginfo_t) == GDB_SI_SIZE);
gdb_static_assert (sizeof (compat_siginfo_t) == GDB_SI_SIZE);
gdb_static_assert (sizeof (ptrace_siginfo_t) == GDB_SI_SIZE);
static_assert (sizeof (compat_x32_siginfo_t) == GDB_SI_SIZE);
static_assert (sizeof (compat_siginfo_t) == GDB_SI_SIZE);
static_assert (sizeof (ptrace_siginfo_t) == GDB_SI_SIZE);
2 changes: 1 addition & 1 deletion gdb/nios2-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static int nios2_dwarf2gdb_regno_map[] =
NIOS2_MPUACC_REGNUM /* 48 */
};

gdb_static_assert (ARRAY_SIZE (nios2_dwarf2gdb_regno_map) == NIOS2_NUM_REGS);
static_assert (ARRAY_SIZE (nios2_dwarf2gdb_regno_map) == NIOS2_NUM_REGS);

/* Implement the dwarf2_reg_to_regnum gdbarch method. */

Expand Down
2 changes: 1 addition & 1 deletion gdb/remote-notif.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static const notif_client *const notifs[] =
&notif_client_stop,
};

gdb_static_assert (ARRAY_SIZE (notifs) == REMOTE_NOTIF_LAST);
static_assert (ARRAY_SIZE (notifs) == REMOTE_NOTIF_LAST);

/* Parse the BUF for the expected notification NC, and send packet to
acknowledge. */
Expand Down
2 changes: 1 addition & 1 deletion gdb/riscv-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ struct riscv_freg_feature : public riscv_register_feature
RISCV_LAST_FP_REGNUM. */
const char *register_name (int regnum) const
{
gdb_static_assert (RISCV_LAST_FP_REGNUM == RISCV_FIRST_FP_REGNUM + 31);
static_assert (RISCV_LAST_FP_REGNUM == RISCV_FIRST_FP_REGNUM + 31);
gdb_assert (regnum >= RISCV_FIRST_FP_REGNUM
&& regnum <= RISCV_LAST_FP_REGNUM);
regnum -= RISCV_FIRST_FP_REGNUM;
Expand Down
6 changes: 3 additions & 3 deletions gdb/symfile-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
/* Verify parameters of target_read_memory_bfd and target_read_memory are
compatible. */

gdb_static_assert (sizeof (CORE_ADDR) >= sizeof (bfd_vma));
gdb_static_assert (sizeof (gdb_byte) == sizeof (bfd_byte));
gdb_static_assert (sizeof (ssize_t) <= sizeof (bfd_size_type));
static_assert (sizeof (CORE_ADDR) >= sizeof (bfd_vma));
static_assert (sizeof (gdb_byte) == sizeof (bfd_byte));
static_assert (sizeof (ssize_t) <= sizeof (bfd_size_type));

/* Provide bfd/ compatible prototype for target_read_memory. Casting would not
be enough as LEN width may differ. */
Expand Down
2 changes: 1 addition & 1 deletion gdb/symtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -6392,7 +6392,7 @@ gdb::array_view<const struct symbol_impl> symbol_impls (symbol_impl);

/* Make sure we saved enough room in struct symbol. */

gdb_static_assert (MAX_SYMBOL_IMPLS <= (1 << SYMBOL_ACLASS_BITS));
static_assert (MAX_SYMBOL_IMPLS <= (1 << SYMBOL_ACLASS_BITS));

/* Register a computed symbol type. ACLASS must be LOC_COMPUTED. OPS
is the ops vector associated with this index. This returns the new
Expand Down
Loading

0 comments on commit 69f6730

Please sign in to comment.