]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/c-style-enum-in-composite.rs
Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyup
[rust.git] / src / test / debuginfo / c-style-enum-in-composite.rs
1 // ignore-tidy-linelength
2 // min-lldb-version: 310
3
4 // compile-flags:-g
5
6 // === GDB TESTS ===================================================================================
7
8 // gdb-command:run
9
10 // gdb-command:print tuple_interior_padding
11 // gdbg-check:$1 = {__0 = 0, __1 = OneHundred}
12 // gdbr-check:$1 = (0, c_style_enum_in_composite::AnEnum::OneHundred)
13
14 // gdb-command:print tuple_padding_at_end
15 // gdbg-check:$2 = {__0 = {__0 = 1, __1 = OneThousand}, __1 = 2}
16 // gdbr-check:$2 = ((1, c_style_enum_in_composite::AnEnum::OneThousand), 2)
17
18 // gdb-command:print tuple_different_enums
19 // gdbg-check:$3 = {__0 = OneThousand, __1 = MountainView, __2 = OneMillion, __3 = Vienna}
20 // gdbr-check:$3 = (c_style_enum_in_composite::AnEnum::OneThousand, c_style_enum_in_composite::AnotherEnum::MountainView, c_style_enum_in_composite::AnEnum::OneMillion, c_style_enum_in_composite::AnotherEnum::Vienna)
21
22 // gdb-command:print padded_struct
23 // gdbg-check:$4 = {a = 3, b = OneMillion, c = 4, d = Toronto, e = 5}
24 // gdbr-check:$4 = c_style_enum_in_composite::PaddedStruct {a: 3, b: c_style_enum_in_composite::AnEnum::OneMillion, c: 4, d: c_style_enum_in_composite::AnotherEnum::Toronto, e: 5}
25
26 // gdb-command:print packed_struct
27 // gdbg-check:$5 = {a = 6, b = OneHundred, c = 7, d = Vienna, e = 8}
28 // gdbr-check:$5 = c_style_enum_in_composite::PackedStruct {a: 6, b: c_style_enum_in_composite::AnEnum::OneHundred, c: 7, d: c_style_enum_in_composite::AnotherEnum::Vienna, e: 8}
29
30 // gdb-command:print non_padded_struct
31 // gdbg-check:$6 = {a = OneMillion, b = MountainView, c = OneThousand, d = Toronto}
32 // gdbr-check:$6 = c_style_enum_in_composite::NonPaddedStruct {a: c_style_enum_in_composite::AnEnum::OneMillion, b: c_style_enum_in_composite::AnotherEnum::MountainView, c: c_style_enum_in_composite::AnEnum::OneThousand, d: c_style_enum_in_composite::AnotherEnum::Toronto}
33
34 // gdb-command:print struct_with_drop
35 // gdbg-check:$7 = {__0 = {a = OneHundred, b = Vienna}, __1 = 9}
36 // gdbr-check:$7 = (c_style_enum_in_composite::StructWithDrop {a: c_style_enum_in_composite::AnEnum::OneHundred, b: c_style_enum_in_composite::AnotherEnum::Vienna}, 9)
37
38 // === LLDB TESTS ==================================================================================
39
40 // lldb-command:run
41
42 // lldb-command:print tuple_interior_padding
43 // lldbg-check:[...]$0 = { 0 = 0 1 = OneHundred }
44 // lldbr-check:((i16, c_style_enum_in_composite::AnEnum)) tuple_interior_padding = { 0 = 0 1 = OneHundred }
45
46 // lldb-command:print tuple_padding_at_end
47 // lldbg-check:[...]$1 = { 0 = { 0 = 1 1 = OneThousand } 1 = 2 }
48 // lldbr-check:(((u64, c_style_enum_in_composite::AnEnum), u64)) tuple_padding_at_end = { 0 = { 0 = 1 1 = OneThousand } 1 = 2 }
49
50 // lldb-command:print tuple_different_enums
51 // lldbg-check:[...]$2 = { 0 = OneThousand 1 = MountainView 2 = OneMillion 3 = Vienna }
52 // lldbr-check:((c_style_enum_in_composite::AnEnum, c_style_enum_in_composite::AnotherEnum, c_style_enum_in_composite::AnEnum, c_style_enum_in_composite::AnotherEnum)) tuple_different_enums = { 0 = c_style_enum_in_composite::AnEnum::OneThousand 1 = c_style_enum_in_composite::AnotherEnum::MountainView 2 = c_style_enum_in_composite::AnEnum::OneMillion 3 = c_style_enum_in_composite::AnotherEnum::Vienna }
53
54 // lldb-command:print padded_struct
55 // lldbg-check:[...]$3 = { a = 3 b = OneMillion c = 4 d = Toronto e = 5 }
56 // lldbr-check:(c_style_enum_in_composite::PaddedStruct) padded_struct = { a = 3 b = c_style_enum_in_composite::AnEnum::OneMillion c = 4 d = Toronto e = 5 }
57
58 // lldb-command:print packed_struct
59 // lldbg-check:[...]$4 = { a = 6 b = OneHundred c = 7 d = Vienna e = 8 }
60 // lldbr-check:(c_style_enum_in_composite::PackedStruct) packed_struct = { a = 6 b = c_style_enum_in_composite::AnEnum::OneHundred c = 7 d = Vienna e = 8 }
61
62 // lldb-command:print non_padded_struct
63 // lldbg-check:[...]$5 = { a = OneMillion b = MountainView c = OneThousand d = Toronto }
64 // lldbr-check:(c_style_enum_in_composite::NonPaddedStruct) non_padded_struct = { a = c_style_enum_in_composite::AnEnum::OneMillion, b = c_style_enum_in_composite::AnotherEnum::MountainView, c = c_style_enum_in_composite::AnEnum::OneThousand, d = c_style_enum_in_composite::AnotherEnum::Toronto }
65
66 // lldb-command:print struct_with_drop
67 // lldbg-check:[...]$6 = { 0 = { a = OneHundred b = Vienna } 1 = 9 }
68 // lldbr-check:((c_style_enum_in_composite::StructWithDrop, i64)) struct_with_drop = { 0 = { a = c_style_enum_in_composite::AnEnum::OneHundred b = c_style_enum_in_composite::AnotherEnum::Vienna } 1 = 9 }
69
70 #![allow(unused_variables)]
71 #![feature(omit_gdb_pretty_printer_section)]
72 #![omit_gdb_pretty_printer_section]
73
74 use self::AnEnum::{OneHundred, OneThousand, OneMillion};
75 use self::AnotherEnum::{MountainView, Toronto, Vienna};
76
77 enum AnEnum {
78     OneHundred = 100,
79     OneThousand = 1000,
80     OneMillion = 1000000
81 }
82
83 enum AnotherEnum {
84     MountainView,
85     Toronto,
86     Vienna
87 }
88
89 struct PaddedStruct {
90     a: i16,
91     b: AnEnum,
92     c: i16,
93     d: AnotherEnum,
94     e: i16
95 }
96
97 #[repr(packed)]
98 struct PackedStruct {
99     a: i16,
100     b: AnEnum,
101     c: i16,
102     d: AnotherEnum,
103     e: i16
104 }
105
106 struct NonPaddedStruct {
107     a: AnEnum,
108     b: AnotherEnum,
109     c: AnEnum,
110     d: AnotherEnum
111 }
112
113 struct StructWithDrop {
114     a: AnEnum,
115     b: AnotherEnum
116 }
117
118 impl Drop for StructWithDrop {
119     fn drop(&mut self) {()}
120 }
121
122 fn main() {
123
124     let tuple_interior_padding = (0_i16, OneHundred);
125     // It will depend on the machine architecture if any padding is actually involved here
126     let tuple_padding_at_end = ((1_u64, OneThousand), 2_u64);
127     let tuple_different_enums = (OneThousand, MountainView, OneMillion, Vienna);
128
129     let padded_struct = PaddedStruct {
130         a: 3,
131         b: OneMillion,
132         c: 4,
133         d: Toronto,
134         e: 5
135     };
136
137     let packed_struct = PackedStruct {
138         a: 6,
139         b: OneHundred,
140         c: 7,
141         d: Vienna,
142         e: 8
143     };
144
145     let non_padded_struct = NonPaddedStruct {
146         a: OneMillion,
147         b: MountainView,
148         c: OneThousand,
149         d: Toronto
150     };
151
152     let struct_with_drop = (StructWithDrop { a: OneHundred, b: Vienna }, 9_i64);
153
154     zzz(); // #break
155 }
156
157 fn zzz() { () }