diff options
author | Tom Tromey <tromey@adacore.com> | 2024-08-26 11:10:54 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2025-03-06 14:17:17 -0700 |
commit | a8551849716c2b29e59547212e3aa69b8f4e2ad8 (patch) | |
tree | 4b6fb2305da41865a1e6b49312a7250048a53bce /gdb/ada-lang.c | |
parent | 7253760b5a0116505a9b13c9f6cbaa457ec8b74f (diff) | |
download | binutils-a8551849716c2b29e59547212e3aa69b8f4e2ad8.zip binutils-a8551849716c2b29e59547212e3aa69b8f4e2ad8.tar.gz binutils-a8551849716c2b29e59547212e3aa69b8f4e2ad8.tar.bz2 |
Use ada_identical_enum_types_p in ada_atr_enum_rep
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.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index aef2b1d..d26139b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -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); |