]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use ada_identical_enum_types_p in ada_atr_enum_rep
authorTom Tromey <tromey@adacore.com>
Mon, 26 Aug 2024 17:10:54 +0000 (11:10 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 6 Mar 2025 21:17:17 +0000 (14:17 -0700)
With the coming changes to GNAT, we may see two distinct but
equivalent enum types in the DWARF.  In this case, it's better to use
ada_identical_enum_types_p rather than types_equal when comparing
these types... something that matters when using 'Enum_Rep.

gdb/ada-lang.c

index aef2b1debba6edcd5c5311386c0ae4174dc42322..d26139b802ffec4b83662ce647be1fcacad95297 100644 (file)
@@ -8758,7 +8758,14 @@ ada_atr_enum_rep (struct expression *exp, enum noside noside, struct type *type,
     type = type->target_type ();
   if (type->code () != TYPE_CODE_ENUM)
     error (_("'Enum_Rep only defined on enum types"));
-  if (!types_equal (type, arg->type ()))
+  /* In some scenarios, GNAT will emit two distinct-but-equivalent
+     enum types.  For example, this can happen with an artificial
+     range type like the index type in:
+
+     type AR is array (Enum_With_Gaps range <>) of MyWord;
+
+     This is why types_equal is not used here.  */
+  if (!ada_identical_enum_types_p (type, arg->type ()))
     error (_("'Enum_Rep requires argument to have same type as enum"));
 
   return value_cast (inttype, arg);