]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/tuple-style-enum-legacy.rs
Rollup merge of #62351 - RalfJung:drop-in-place, r=cramertj
[rust.git] / src / test / debuginfo / tuple-style-enum-legacy.rs
1 // ignore-tidy-linelength
2 // min-lldb-version: 310
3
4 // As long as LLVM 5 and LLVM 6 are supported, we want to test the
5 // enum debuginfo fallback mode.  Once those are desupported, this
6 // test can be removed, as there is another (non-"legacy") test that
7 // tests the new mode.
8 // ignore-llvm-version: 7.0 - 9.9.9
9 // ignore-gdb-version: 7.11.90 - 7.12.9
10 // ignore-gdb-version: 8.2 - 9.9
11
12 // compile-flags:-g
13
14 // === GDB TESTS ===================================================================================
15
16 // gdb-command:set print union on
17 // gdb-command:run
18
19 // gdb-command:print case1
20 // gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
21 // gdbr-check:$1 = tuple_style_enum_legacy::Regular::Case1(0, 31868, 31868, 31868, 31868)
22
23 // gdb-command:print case2
24 // gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
25 // gdbr-check:$2 = tuple_style_enum_legacy::Regular::Case2(0, 286331153, 286331153)
26
27 // gdb-command:print case3
28 // gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}}
29 // gdbr-check:$3 = tuple_style_enum_legacy::Regular::Case3(0, 6438275382588823897)
30
31 // gdb-command:print univariant
32 // gdbg-check:$4 = {{__0 = -1}}
33 // gdbr-check:$4 = tuple_style_enum_legacy::Univariant::TheOnlyCase(-1)
34
35
36 // === LLDB TESTS ==================================================================================
37
38 // lldb-command:run
39
40 // lldb-command:print case1
41 // lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868)
42 // lldbr-check:(tuple_style_enum_legacy::Regular::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 }
43
44 // lldb-command:print case2
45 // lldbg-check:[...]$1 = Case2(0, 286331153, 286331153)
46 // lldbr-check:(tuple_style_enum_legacy::Regular::Case2) case2 = Case2 { tuple_style_enum_legacy::Regular::Case1: 0, tuple_style_enum_legacy::Regular::Case2: 286331153, tuple_style_enum_legacy::Regular::Case3: 286331153 }
47
48 // lldb-command:print case3
49 // lldbg-check:[...]$2 = Case3(0, 6438275382588823897)
50 // lldbr-check:(tuple_style_enum_legacy::Regular::Case3) case3 = Case3 { tuple_style_enum_legacy::Regular::Case1: 0, tuple_style_enum_legacy::Regular::Case2: 6438275382588823897 }
51
52 // lldb-command:print univariant
53 // lldbg-check:[...]$3 = TheOnlyCase(-1)
54 // lldbr-check:(tuple_style_enum_legacy::Univariant) univariant = { tuple_style_enum_legacy::TheOnlyCase = { = -1 } }
55
56 #![allow(unused_variables)]
57 #![feature(omit_gdb_pretty_printer_section)]
58 #![omit_gdb_pretty_printer_section]
59
60 use self::Regular::{Case1, Case2, Case3};
61 use self::Univariant::TheOnlyCase;
62
63 // The first element is to ensure proper alignment, irrespective of the machines word size. Since
64 // the size of the discriminant value is machine dependent, this has be taken into account when
65 // datatype layout should be predictable as in this case.
66 enum Regular {
67     Case1(u64, u16, u16, u16, u16),
68     Case2(u64, u32, u32),
69     Case3(u64, u64)
70 }
71
72 enum Univariant {
73     TheOnlyCase(i64)
74 }
75
76 fn main() {
77
78     // In order to avoid endianness trouble all of the following test values consist of a single
79     // repeated byte. This way each interpretation of the union should look the same, no matter if
80     // this is a big or little endian machine.
81
82     // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
83     // 0b01111100011111000111110001111100 = 2088533116
84     // 0b0111110001111100 = 31868
85     // 0b01111100 = 124
86     let case1 = Case1(0, 31868, 31868, 31868, 31868);
87
88     // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
89     // 0b00010001000100010001000100010001 = 286331153
90     // 0b0001000100010001 = 4369
91     // 0b00010001 = 17
92     let case2 = Case2(0, 286331153, 286331153);
93
94     // 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
95     // 0b01011001010110010101100101011001 = 1499027801
96     // 0b0101100101011001 = 22873
97     // 0b01011001 = 89
98     let case3 = Case3(0, 6438275382588823897);
99
100     let univariant = TheOnlyCase(-1);
101
102     zzz(); // #break
103 }
104
105 fn zzz() {()}