aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-08-26 11:30:01 -0600
committerTom Tromey <tromey@adacore.com>2024-09-09 11:47:17 -0600
commit2bf0419eea579e0b4a8935be91f34e6871263096 (patch)
tree85ef81821cc6ace826f0d4acff0205d1e21d2ea1
parent511c6575b2febee533a4d8796647bbabc2c27249 (diff)
downloadgdb-2bf0419eea579e0b4a8935be91f34e6871263096.zip
gdb-2bf0419eea579e0b4a8935be91f34e6871263096.tar.gz
gdb-2bf0419eea579e0b4a8935be91f34e6871263096.tar.bz2
Move enum size check into ada_identical_enum_types_p
Currently, the callers of ada_identical_enum_types_p must check that both enum types have the same number of members. In another series I'm working on, it was convenient to move this check into the callee instead; and I broke this patch out to make that series a little simpler. Approved-By: Tom de Vries <tdevries@suse.de>
-rw-r--r--gdb/ada-lang.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 57f2b2b..0f7100d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3814,8 +3814,6 @@ ada_resolve_enum (std::vector<struct block_symbol> &syms,
for (int i = 0; i < syms.size (); ++i)
{
struct type *type2 = ada_check_typedef (syms[i].symbol->type ());
- if (type1->num_fields () != type2->num_fields ())
- continue;
if (strcmp (type1->name (), type2->name ()) != 0)
continue;
if (ada_identical_enum_types_p (type1, type2))
@@ -4970,8 +4968,7 @@ is_nondebugging_type (struct type *type)
that are deemed "identical" for practical purposes.
This function assumes that TYPE1 and TYPE2 are both TYPE_CODE_ENUM
- types and that their number of enumerals is identical (in other
- words, type1->num_fields () == type2->num_fields ()). */
+ types. */
static bool
ada_identical_enum_types_p (struct type *type1, struct type *type2)
@@ -4981,6 +4978,9 @@ ada_identical_enum_types_p (struct type *type1, struct type *type2)
number of enumerals and that all enumerals have the same
underlying value and name. */
+ if (type1->num_fields () != type2->num_fields ())
+ return false;
+
/* All enums in the type should have an identical underlying value. */
for (int i = 0; i < type1->num_fields (); i++)
if (type1->field (i).loc_enumval () != type2->field (i).loc_enumval ())
@@ -5046,12 +5046,6 @@ symbols_are_identical_enums (const std::vector<struct block_symbol> &syms)
if (syms[i].symbol->value_longest () != syms[0].symbol->value_longest ())
return 0;
- /* Quick check: They should all have the same number of enumerals. */
- for (i = 1; i < syms.size (); i++)
- if (syms[i].symbol->type ()->num_fields ()
- != syms[0].symbol->type ()->num_fields ())
- return 0;
-
/* All the sanity checks passed, so we might have a set of
identical enumeration types. Perform a more complete
comparison of the type of each symbol. */