]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/c-style-enum-in-composite.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / debuginfo / c-style-enum-in-composite.rs
1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-tidy-linelength
12 // min-lldb-version: 310
13
14 // compile-flags:-g
15
16 // === GDB TESTS ===================================================================================
17
18 // gdb-command:run
19
20 // gdb-command:print tuple_interior_padding
21 // gdbg-check:$1 = {__0 = 0, __1 = OneHundred}
22 // gdbr-check:$1 = (0, c_style_enum_in_composite::AnEnum::OneHundred)
23
24 // gdb-command:print tuple_padding_at_end
25 // gdbg-check:$2 = {__0 = {__0 = 1, __1 = OneThousand}, __1 = 2}
26 // gdbr-check:$2 = ((1, c_style_enum_in_composite::AnEnum::OneThousand), 2)
27
28 // gdb-command:print tuple_different_enums
29 // gdbg-check:$3 = {__0 = OneThousand, __1 = MountainView, __2 = OneMillion, __3 = Vienna}
30 // 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)
31
32 // gdb-command:print padded_struct
33 // gdbg-check:$4 = {a = 3, b = OneMillion, c = 4, d = Toronto, e = 5}
34 // 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}
35
36 // gdb-command:print packed_struct
37 // gdbg-check:$5 = {a = 6, b = OneHundred, c = 7, d = Vienna, e = 8}
38 // 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}
39
40 // gdb-command:print non_padded_struct
41 // gdbg-check:$6 = {a = OneMillion, b = MountainView, c = OneThousand, d = Toronto}
42 // 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}
43
44 // gdb-command:print struct_with_drop
45 // gdbg-check:$7 = {__0 = {a = OneHundred, b = Vienna}, __1 = 9}
46 // 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)
47
48 // === LLDB TESTS ==================================================================================
49
50 // lldb-command:run
51
52 // lldb-command:print tuple_interior_padding
53 // lldb-check:[...]$0 = (0, OneHundred)
54
55 // lldb-command:print tuple_padding_at_end
56 // lldb-check:[...]$1 = ((1, OneThousand), 2)
57 // lldb-command:print tuple_different_enums
58 // lldb-check:[...]$2 = (OneThousand, MountainView, OneMillion, Vienna)
59
60 // lldb-command:print padded_struct
61 // lldb-check:[...]$3 = PaddedStruct { a: 3, b: OneMillion, c: 4, d: Toronto, e: 5 }
62
63 // lldb-command:print packed_struct
64 // lldb-check:[...]$4 = PackedStruct { a: 6, b: OneHundred, c: 7, d: Vienna, e: 8 }
65
66 // lldb-command:print non_padded_struct
67 // lldb-check:[...]$5 = NonPaddedStruct { a: OneMillion, b: MountainView, c: OneThousand, d: Toronto }
68
69 // lldb-command:print struct_with_drop
70 // lldb-check:[...]$6 = (StructWithDrop { a: OneHundred, b: Vienna }, 9)
71
72 #![allow(unused_variables)]
73 #![feature(omit_gdb_pretty_printer_section)]
74 #![omit_gdb_pretty_printer_section]
75
76 use self::AnEnum::{OneHundred, OneThousand, OneMillion};
77 use self::AnotherEnum::{MountainView, Toronto, Vienna};
78
79 enum AnEnum {
80     OneHundred = 100,
81     OneThousand = 1000,
82     OneMillion = 1000000
83 }
84
85 enum AnotherEnum {
86     MountainView,
87     Toronto,
88     Vienna
89 }
90
91 struct PaddedStruct {
92     a: i16,
93     b: AnEnum,
94     c: i16,
95     d: AnotherEnum,
96     e: i16
97 }
98
99 #[repr(packed)]
100 struct PackedStruct {
101     a: i16,
102     b: AnEnum,
103     c: i16,
104     d: AnotherEnum,
105     e: i16
106 }
107
108 struct NonPaddedStruct {
109     a: AnEnum,
110     b: AnotherEnum,
111     c: AnEnum,
112     d: AnotherEnum
113 }
114
115 struct StructWithDrop {
116     a: AnEnum,
117     b: AnotherEnum
118 }
119
120 impl Drop for StructWithDrop {
121     fn drop(&mut self) {()}
122 }
123
124 fn main() {
125
126     let tuple_interior_padding = (0_i16, OneHundred);
127     // It will depend on the machine architecture if any padding is actually involved here
128     let tuple_padding_at_end = ((1_u64, OneThousand), 2_u64);
129     let tuple_different_enums = (OneThousand, MountainView, OneMillion, Vienna);
130
131     let padded_struct = PaddedStruct {
132         a: 3,
133         b: OneMillion,
134         c: 4,
135         d: Toronto,
136         e: 5
137     };
138
139     let packed_struct = PackedStruct {
140         a: 6,
141         b: OneHundred,
142         c: 7,
143         d: Vienna,
144         e: 8
145     };
146
147     let non_padded_struct = NonPaddedStruct {
148         a: OneMillion,
149         b: MountainView,
150         c: OneThousand,
151         d: Toronto
152     };
153
154     let struct_with_drop = (StructWithDrop { a: OneHundred, b: Vienna }, 9_i64);
155
156     zzz(); // #break
157 }
158
159 fn zzz() { () }