Fix bug in quirk_rust_enum

Message ID 20200619205100.25400-1-tromey@adacore.com
State New
Headers show
Series
  • Fix bug in quirk_rust_enum
Related show

Commit Message

Tom Tromey June 19, 2020, 8:51 p.m.
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-19  Tom Tromey  <tromey@adacore.com>

	* dwarf2/read.c (quirk_rust_enum): Correctly call
	alloc_rust_variant for default-less enum.
---
 gdb/ChangeLog     | 5 +++++
 gdb/dwarf2/read.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
2.21.3

Comments

Tom Tromey June 30, 2020, 1:57 p.m. | #1
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:


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

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

I'm checking this in now.

Tom

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 4dc9ad6c99b..b097f624b6c 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -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));
     }