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