Fix bug in quirk_rust_enum
authorTom Tromey <tromey@adacore.com>
Tue, 30 Jun 2020 13:57:35 +0000 (07:57 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 30 Jun 2020 13:57:35 +0000 (07:57 -0600)
Tom de Vries pointed out that some Rust tests were failing after the
variant part rewrite.  He sent an executable, which helped track down
this bug.

quirk_rust_enum was passing 1 to alloc_rust_variant in one case.
However, a comment earlier says:

      /* We don't need a range entry for the discriminant, but we do
 need one for every other field, as there is no default
 variant.  */

In this case, we must pass -1 for this parameter.  That is what this
patch implements.

gdb/ChangeLog
2020-06-30  Tom Tromey  <tromey@adacore.com>

* dwarf2/read.c (quirk_rust_enum): Correctly call
alloc_rust_variant for default-less enum.

gdb/ChangeLog
gdb/dwarf2/read.c

index ddd831e7311ce7d8473ca7aa66a44da8cefaa1bc..d64f572e071d14c6bce2a05c5602dfccd1b29351 100644 (file)
@@ -1,3 +1,8 @@
+2020-06-30  Tom Tromey  <tromey@adacore.com>
+
+       * dwarf2/read.c (quirk_rust_enum): Correctly call
+       alloc_rust_variant for default-less enum.
+
 2020-06-30  Tom Tromey  <tromey@adacore.com>
 
        PR build/26183:
index 4dc9ad6c99bc09dcf23daae1961a66fa24b10b69..b097f624b6c4882c82718773145bed2614978a07 100644 (file)
@@ -9691,7 +9691,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
        }
 
       /* Indicate that this is a variant type.  */
-      alloc_rust_variant (&objfile->objfile_obstack, type, 0, 1,
+      alloc_rust_variant (&objfile->objfile_obstack, type, 0, -1,
                          gdb::array_view<discriminant_range> (ranges,
                                                               n_fields - 1));
     }
This page took 0.03402 seconds and 4 git commands to generate.