From a037790ec570ae9f9bf535cbce25f238f90e8b4a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 29 Mar 2018 11:49:59 -0600 Subject: Fix crash in quirk_rust_enum I noticed that quirk_rust_enum can crash when presented with a union whose fields are all scalar types. This patch adds a new test case and fixes the bug. Regression tested on Fedora 26 x86-64. 2018-04-17 Tom Tromey * dwarf2read.c (quirk_rust_enum): Handle unions correctly. 2018-04-17 Tom Tromey * gdb.rust/simple.rs (Union): New type. (main): New local "u". * gdb.rust/simple.exp (test_one_slice): Add new test case. --- gdb/testsuite/gdb.rust/simple.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gdb/testsuite/gdb.rust/simple.rs') diff --git a/gdb/testsuite/gdb.rust/simple.rs b/gdb/testsuite/gdb.rust/simple.rs index b2b5dfe..e5bbe52 100644 --- a/gdb/testsuite/gdb.rust/simple.rs +++ b/gdb/testsuite/gdb.rust/simple.rs @@ -80,6 +80,11 @@ struct ParametrizedStruct { value: T } +union Union { + f1: i8, + f2: u8, +} + fn main () { let a = (); let b : [i32; 0] = []; @@ -153,6 +158,8 @@ fn main () { value: 0, }; + let u = Union { f2: 255 }; + println!("{}, {}", x.0, x.1); // set breakpoint here println!("{}", diff2(92, 45)); empty(); -- cgit v1.1