]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/struct-in-enum.rs
Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyup
[rust.git] / src / test / debuginfo / struct-in-enum.rs
1 // ignore-tidy-linelength
2 // min-lldb-version: 310
3 // ignore-gdb-version: 7.11.90 - 7.12.9
4 // ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155
5
6 // compile-flags:-g
7
8 // === GDB TESTS ===================================================================================
9
10 // gdb-command:set print union on
11 // gdb-command:run
12
13 // gdb-command:print case1
14 // gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = {x = 2088533116, y = 2088533116, z = 31868}}, {RUST$ENUM$DISR = Case1, [...]}}
15 // gdbr-check:$1 = struct_in_enum::Regular::Case1(0, struct_in_enum::Struct {x: 2088533116, y: 2088533116, z: 31868})
16
17 // gdb-command:print case2
18 // gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 1229782938247303441, __2 = 4369}}
19 // gdbr-check:$2 = struct_in_enum::Regular::Case2(0, 1229782938247303441, 4369)
20
21 // gdb-command:print univariant
22 // gdbg-check:$3 = {{__0 = {x = 123, y = 456, z = 789}}}
23 // gdbr-check:$3 = struct_in_enum::Univariant::TheOnlyCase(struct_in_enum::Struct {x: 123, y: 456, z: 789})
24
25
26 // === LLDB TESTS ==================================================================================
27
28 // lldb-command:run
29
30 // lldb-command:print case1
31 // lldb-check:[...]$0 = Case1(0, Struct { x: 2088533116, y: 2088533116, z: 31868 })
32 // lldb-command:print case2
33 // lldb-check:[...]$1 = Case2(0, 1229782938247303441, 4369)
34
35 // lldb-command:print univariant
36 // lldb-check:[...]$2 = TheOnlyCase(Struct { x: 123, y: 456, z: 789 })
37
38 #![allow(unused_variables)]
39 #![feature(omit_gdb_pretty_printer_section)]
40 #![omit_gdb_pretty_printer_section]
41
42 use self::Regular::{Case1, Case2};
43 use self::Univariant::TheOnlyCase;
44
45 struct Struct {
46     x: u32,
47     y: i32,
48     z: i16
49 }
50
51 // The first element is to ensure proper alignment, irrespective of the machines word size. Since
52 // the size of the discriminant value is machine dependent, this has be taken into account when
53 // datatype layout should be predictable as in this case.
54 enum Regular {
55     Case1(u64, Struct),
56     Case2(u64, u64, i16)
57 }
58
59 enum Univariant {
60     TheOnlyCase(Struct)
61 }
62
63 fn main() {
64
65     // In order to avoid endianness trouble all of the following test values consist of a single
66     // repeated byte. This way each interpretation of the union should look the same, no matter if
67     // this is a big or little endian machine.
68
69     // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
70     // 0b01111100011111000111110001111100 = 2088533116
71     // 0b0111110001111100 = 31868
72     // 0b01111100 = 124
73     let case1 = Case1(0, Struct { x: 2088533116, y: 2088533116, z: 31868 });
74
75     // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
76     // 0b00010001000100010001000100010001 = 286331153
77     // 0b0001000100010001 = 4369
78     // 0b00010001 = 17
79     let case2 = Case2(0, 1229782938247303441, 4369);
80
81     let univariant = TheOnlyCase(Struct { x: 123, y: 456, z: 789 });
82
83     zzz(); // #break
84 }
85
86 fn zzz() {()}