]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Allow for anonymous Ada enumeration types
authorTom Tromey <tromey@adacore.com>
Mon, 9 Sep 2024 16:57:56 +0000 (10:57 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 6 Mar 2025 21:17:17 +0000 (14:17 -0700)
With some forthcoming changes to GNAT, gdb might see a nameless enum
in ada_resolve_enum, causing a crash.  This patch allows an anonymous
enum type to be considered identical to a named type when the contents
are identical.

gdb/ada-lang.c

index b7e24ef6b2c2f9083e1eace3fde26c57349bb959..95ceb10d3ab83fed3b8c2646ed83ee8ef17b2d18 100644 (file)
@@ -3796,7 +3796,10 @@ 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 (strcmp (type1->name (), type2->name ()) != 0)
+      /* We let an anonymous enum type match a non-anonymous one.  */
+      if (type1->name () != nullptr
+         && type2->name () != nullptr
+         && strcmp (type1->name (), type2->name ()) != 0)
        continue;
       if (ada_identical_enum_types_p (type1, type2))
        return i;