]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/generic-tuple-style-enum-legacy.rs
Simplify Cache wrapper to single type, impl Deref on it, fix all compilation errors...
[rust.git] / src / test / debuginfo / generic-tuple-style-enum-legacy.rs
1 // ignore-tidy-linelength
2 // min-lldb-version: 310
3 // ignore-gdb-version: 7.11.90 - 7.12.9
4
5 // As long as LLVM 5 and LLVM 6 are supported, we want to test the
6 // enum debuginfo fallback mode.  Once those are desupported, this
7 // test can be removed, as there is another (non-"legacy") test that
8 // tests the new mode.
9 // ignore-llvm-version: 7.0 - 9.9.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 = generic_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 = generic_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 = generic_tuple_style_enum_legacy::Regular::Case3(0, 6438275382588823897)
30
31 // gdb-command:print univariant
32 // gdbg-check:$4 = {{__0 = -1}}
33 // gdbr-check:$4 = generic_tuple_style_enum_legacy::Univariant<i64>::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:(generic_tuple_style_enum_legacy::Regular<u16, u32, u64>::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 }
43
44 // lldb-command:print case2
45 // lldbg-check:[...]$1 = Case2(0, 286331153, 286331153)
46 // lldbr-check:(generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case2) case2 = Regular<i16, i32, i64>::Case2 { generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case1: 0, generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case2: 286331153, generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case3: 286331153 }
47
48 // lldb-command:print case3
49 // lldbg-check:[...]$2 = Case3(0, 6438275382588823897)
50 // lldbr-check:(generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case3) case3 = Regular<i16, i32, i64>::Case3 { generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case1: 0, generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case2: 6438275382588823897 }
51
52 // lldb-command:print univariant
53 // lldbg-check:[...]$3 = TheOnlyCase(-1)
54 // lldbr-check:(generic_tuple_style_enum_legacy::Univariant<i64>) univariant = { generic_tuple_style_enum_legacy::TheOnlyCase = { = -1 } }
55
56 #![feature(omit_gdb_pretty_printer_section)]
57 #![omit_gdb_pretty_printer_section]
58
59 use self::Regular::{Case1, Case2, Case3};
60 use self::Univariant::TheOnlyCase;
61
62 // NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
63 // substituted with something of size `xx` bits and the same alignment as an integer type of the
64 // same size.
65
66 // The first element is to ensure proper alignment, irrespective of the machines word size. Since
67 // the size of the discriminant value is machine dependent, this has be taken into account when
68 // datatype layout should be predictable as in this case.
69 enum Regular<T16, T32, T64> {
70     Case1(T64, T16, T16, T16, T16),
71     Case2(T64, T32, T32),
72     Case3(T64, T64)
73 }
74
75 enum Univariant<T64> {
76     TheOnlyCase(T64)
77 }
78
79 fn main() {
80
81     // In order to avoid endianness trouble all of the following test values consist of a single
82     // repeated byte. This way each interpretation of the union should look the same, no matter if
83     // this is a big or little endian machine.
84
85     // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
86     // 0b01111100011111000111110001111100 = 2088533116
87     // 0b0111110001111100 = 31868
88     // 0b01111100 = 124
89     let case1: Regular<u16, u32, u64> = Case1(0_u64, 31868_u16, 31868_u16, 31868_u16, 31868_u16);
90
91     // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
92     // 0b00010001000100010001000100010001 = 286331153
93     // 0b0001000100010001 = 4369
94     // 0b00010001 = 17
95     let case2: Regular<i16, i32, i64> = Case2(0_i64, 286331153_i32, 286331153_i32);
96
97     // 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
98     // 0b01011001010110010101100101011001 = 1499027801
99     // 0b0101100101011001 = 22873
100     // 0b01011001 = 89
101     let case3: Regular<i16, i32, i64> = Case3(0_i64, 6438275382588823897_i64);
102
103     let univariant = TheOnlyCase(-1_i64);
104
105     zzz(); // #break
106 }
107
108 fn zzz() { () }