From 0d1703b8fb611f978577a70ad6aa308a12a53980 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 27 Apr 2022 14:32:49 -0600 Subject: [PATCH] Remove "typedef enum ..." I noticed a few spots in GDB that use "typedef enum". However, in C++ this isn't as useful, as the tag is automatically entered as a typedef. This patch removes most uses of "typedef enum" -- the exceptions being in some nat-* code I can't compile, and glibc_thread_db.h, which I think is more or less a copy of some C code from elsewhere. Tested by rebuilding. --- gdb/arm-tdep.c | 8 ++++---- gdb/break-catch-fork.c | 5 ++--- gdb/command.h | 5 ++--- gdb/f-exp.y | 2 +- gdb/ia64-tdep.c | 4 ++-- gdb/jit.h | 4 ++-- gdb/linespec.c | 3 +-- gdb/nat/windows-nat.h | 4 ++-- gdb/nat/x86-dregs.c | 2 +- gdb/psympriv.h | 2 +- gdb/python/py-event.h | 4 ++-- gdb/symtab.h | 6 +++--- gdb/xtensa-tdep.c | 8 ++++---- gdb/xtensa-tdep.h | 16 ++++++++-------- 14 files changed, 35 insertions(+), 38 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 7274752c2b9..aa5d8e6e6bd 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -10701,18 +10701,18 @@ enum arm_record_result ARM_RECORD_FAILURE = 1 }; -typedef enum +enum arm_record_strx_t { ARM_RECORD_STRH=1, ARM_RECORD_STRD -} arm_record_strx_t; +}; -typedef enum +enum record_type_t { ARM_RECORD=1, THUMB_RECORD, THUMB2_RECORD -} record_type_t; +}; static int diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c index c2c87e89361..ca3c44f9381 100644 --- a/gdb/break-catch-fork.c +++ b/gdb/break-catch-fork.c @@ -197,12 +197,11 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch, install_breakpoint (0, std::move (c), 1); } -typedef enum +enum catch_fork_kind { catch_fork_temporary, catch_vfork_temporary, catch_fork_permanent, catch_vfork_permanent -} -catch_fork_kind; +}; static void catch_fork_command_1 (const char *arg, int from_tty, diff --git a/gdb/command.h b/gdb/command.h index cd798146ae0..d901da3c8cb 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -71,7 +71,7 @@ enum command_class }; /* Types of "set" or "show" command. */ -typedef enum var_types +enum var_types { /* "on" or "off". *VAR is a bool which is true for on, false for off. */ @@ -120,8 +120,7 @@ typedef enum var_types *VAR is a char pointer to the name of the element that we find. */ var_enum - } -var_types; + }; /* Return true if a setting of type VAR_TYPE is backed with type T. diff --git a/gdb/f-exp.y b/gdb/f-exp.y index adc59a52a05..90cc2c65c7b 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1639,7 +1639,7 @@ yylex (void) { std::string tmp = copy_name (yylval.sval); struct block_symbol result; - const enum domain_enum_tag lookup_domains[] = + const domain_enum lookup_domains[] = { STRUCT_DOMAIN, VAR_DOMAIN, diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 69a4b4db4fd..dd6d5b199b2 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -75,7 +75,7 @@ static gdb::optional ktab_buf; /* An enumeration of the different IA-64 instruction types. */ -typedef enum instruction_type +enum instruction_type { A, /* Integer ALU ; I-unit or M-unit */ I, /* Non-ALU integer; I-unit */ @@ -85,7 +85,7 @@ typedef enum instruction_type L, /* Extended (L+X) ; I-unit */ X, /* Extended (L+X) ; I-unit */ undefined /* undefined or reserved */ -} instruction_type; +}; /* We represent IA-64 PC addresses as the value of the instruction pointer or'd with some bit combination in the low nibble which diff --git a/gdb/jit.h b/gdb/jit.h index 274ce456f47..68547637b0b 100644 --- a/gdb/jit.h +++ b/gdb/jit.h @@ -28,12 +28,12 @@ struct minimal_symbol; these actions. These values are used by the inferior, so the values of these enums cannot be changed. */ -typedef enum +enum jit_actions_t { JIT_NOACTION = 0, JIT_REGISTER, JIT_UNREGISTER -} jit_actions_t; +}; /* This struct describes a single symbol file in a linked list of symbol files describing generated code. As the inferior generates diff --git a/gdb/linespec.c b/gdb/linespec.c index 3cbb8f821f1..c9558c8ae36 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -228,7 +228,7 @@ struct symbol_searcher_collect_info /* Token types */ -enum ls_token_type +enum linespec_token_type { /* A keyword */ LSTOKEN_KEYWORD = 0, @@ -251,7 +251,6 @@ enum ls_token_type /* Consumed token */ LSTOKEN_CONSUMED }; -typedef enum ls_token_type linespec_token_type; /* List of keywords. This is NULL-terminated so that it can be used as enum completer. */ diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index 29fd0a3a69b..27b653674c3 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -129,12 +129,12 @@ struct pending_stop DEBUG_EVENT event; }; -typedef enum +enum handle_exception_result { HANDLE_EXCEPTION_UNHANDLED = 0, HANDLE_EXCEPTION_HANDLED, HANDLE_EXCEPTION_IGNORED -} handle_exception_result; +}; /* A single Windows process. An object of this type (or subclass) is created by the client. Some methods must be provided by the client diff --git a/gdb/nat/x86-dregs.c b/gdb/nat/x86-dregs.c index 230b99c0a23..94de0265cf6 100644 --- a/gdb/nat/x86-dregs.c +++ b/gdb/nat/x86-dregs.c @@ -206,7 +206,7 @@ x86_get_debug_register_length () #define X86_DR_WATCH_HIT(dr6, i) ((dr6) & (1 << (i))) /* Types of operations supported by x86_handle_nonaligned_watchpoint. */ -typedef enum { WP_INSERT, WP_REMOVE, WP_COUNT } x86_wp_op_t; +enum x86_wp_op_t { WP_INSERT, WP_REMOVE, WP_COUNT }; /* Print the values of the mirrored debug registers. */ diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 9964c102403..677a57edee8 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -71,7 +71,7 @@ struct partial_symbol /* Name space code. */ - ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS; + ENUM_BITFIELD(domain_enum) domain : SYMBOL_DOMAIN_BITS; /* Address class (for info_symbols). Note that we don't allow synthetic "aclass" values here at present, simply because there's diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h index 56e53b7a1e7..831dd10fc85 100644 --- a/gdb/python/py-event.h +++ b/gdb/python/py-event.h @@ -45,13 +45,13 @@ extern int emit_exited_event (const LONGEST *exit_code, struct inferior *inf); /* For inferior function call events, discriminate whether event is before or after the call. */ -typedef enum +enum inferior_call_kind { /* Before the call */ INFERIOR_CALL_PRE, /* after the call */ INFERIOR_CALL_POST, -} inferior_call_kind; +}; extern int emit_inferior_call_event (inferior_call_kind kind, ptid_t thread, CORE_ADDR addr); diff --git a/gdb/symtab.h b/gdb/symtab.h index 8c2837cfa8b..b1cf84f756f 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -866,7 +866,7 @@ struct minimal_symbol : public general_symbol_info /* Different name domains for symbols. Looking up a symbol specifies a domain and ignores symbol definitions in other name domains. */ -typedef enum domain_enum_tag +enum domain_enum { /* UNDEF_DOMAIN is used when a domain has not been discovered or none of the following apply. This usually indicates an error either @@ -899,7 +899,7 @@ typedef enum domain_enum_tag /* This must remain last. */ NR_DOMAINS -} domain_enum; +}; /* The number of bits in a symbol used to represent the domain. */ @@ -1418,7 +1418,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack /* Domain code. */ - ENUM_BITFIELD(domain_enum_tag) m_domain : SYMBOL_DOMAIN_BITS; + ENUM_BITFIELD(domain_enum) m_domain : SYMBOL_DOMAIN_BITS; /* Address class. This holds an index into the 'symbol_impls' table. The actual enum address_class value is stored there, diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 89bdd7ffd28..b6558838e44 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -2058,7 +2058,7 @@ call0_ret (CORE_ADDR start_pc, CORE_ADDR finish_pc) The purpose of this is to simplify prologue analysis by separating instruction decoding (libisa) from the semantics of prologue analysis. */ -typedef enum +enum xtensa_insn_kind { c0opc_illegal, /* Unknown to libisa (invalid) or 'ill' opcode. */ c0opc_uninteresting, /* Not interesting for Call0 prologue analysis. */ @@ -2079,7 +2079,7 @@ typedef enum c0opc_rfwo, /* RFWO instruction. */ c0opc_rfwu, /* RFWU instruction. */ c0opc_NrOf /* Number of opcode classifications. */ -} xtensa_insn_kind; +}; /* Return true, if OPCNAME is RSR, WRS, or XSR instruction. */ @@ -2753,12 +2753,12 @@ execute_s32e (struct gdbarch *gdbarch, int at, int as, int offset, CORE_ADDR wb) #define XTENSA_MAX_WINDOW_INTERRUPT_HANDLER_LEN 200 -typedef enum +enum xtensa_exception_handler_t { xtWindowOverflow, xtWindowUnderflow, xtNoExceptionHandler -} xtensa_exception_handler_t; +}; /* Execute instruction stream from current PC until hitting RFWU or RFWO. Return type of Xtensa Window Interrupt Handler on success. */ diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h index a1e7188d523..1840ef98b49 100644 --- a/gdb/xtensa-tdep.h +++ b/gdb/xtensa-tdep.h @@ -31,7 +31,7 @@ /* Xtensa register type. */ -typedef enum +enum xtensa_register_type_t { xtRegisterTypeArRegfile = 1, /* Register File ar0..arXX. */ xtRegisterTypeSpecialReg, /* CPU states, such as PS, Booleans, (rsr). */ @@ -43,14 +43,14 @@ typedef enum xtRegisterTypeWindow, /* Live window registers (a0..a15). */ xtRegisterTypeVirtual, /* PC, FP. */ xtRegisterTypeUnknown -} xtensa_register_type_t; +}; /* Xtensa register group. */ #define XTENSA_MAX_COPROCESSOR 0x10 /* Number of Xtensa coprocessors. */ -typedef enum +enum xtensa_register_group_t { xtRegisterGroupUnknown = 0, xtRegisterGroupRegFile = 0x0001, /* Register files without ARx. */ @@ -75,16 +75,16 @@ typedef enum xtRegisterGroupCP6 = 0x40000000, /* CP6. */ xtRegisterGroupCP7 = 0x80000000, /* CP7. */ -} xtensa_register_group_t; +}; /* Xtensa target flags. */ -typedef enum +enum xtensa_target_flags_t { xtTargetFlagsNonVisibleRegs = 0x0001, xtTargetFlagsUseFetchStore = 0x0002, -} xtensa_target_flags_t; +}; /* Mask. */ @@ -143,11 +143,11 @@ typedef struct /* Call-ABI for stack frame. */ -typedef enum +enum call_abi_t { CallAbiDefault = 0, /* Any 'callX' instructions; default stack. */ CallAbiCall0Only, /* Only 'call0' instructions; flat stack. */ -} call_abi_t; +}; struct ctype_cache -- 2.30.2