]> git.proxmox.com Git - rustc.git/blob - src/test/debuginfo/c-style-enum-in-composite.rs
Imported Upstream version 1.0.0~beta.3
[rustc.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 #![omit_gdb_pretty_printer_section]
68
69 use self::AnEnum::{OneHundred, OneThousand, OneMillion};
70 use self::AnotherEnum::{MountainView, Toronto, Vienna};
71
72 enum AnEnum {
73 OneHundred = 100,
74 OneThousand = 1000,
75 OneMillion = 1000000
76 }
77
78 enum AnotherEnum {
79 MountainView,
80 Toronto,
81 Vienna
82 }
83
84 struct PaddedStruct {
85 a: i16,
86 b: AnEnum,
87 c: i16,
88 d: AnotherEnum,
89 e: i16
90 }
91
92 #[repr(packed)]
93 struct PackedStruct {
94 a: i16,
95 b: AnEnum,
96 c: i16,
97 d: AnotherEnum,
98 e: i16
99 }
100
101 struct NonPaddedStruct {
102 a: AnEnum,
103 b: AnotherEnum,
104 c: AnEnum,
105 d: AnotherEnum
106 }
107
108 struct StructWithDrop {
109 a: AnEnum,
110 b: AnotherEnum
111 }
112
113 impl Drop for StructWithDrop {
114 fn drop(&mut self) {()}
115 }
116
117 fn main() {
118
119 let tuple_interior_padding = (0_i16, OneHundred);
120 // It will depend on the machine architecture if any padding is actually involved here
121 let tuple_padding_at_end = ((1_u64, OneThousand), 2_u64);
122 let tuple_different_enums = (OneThousand, MountainView, OneMillion, Vienna);
123
124 let padded_struct = PaddedStruct {
125 a: 3,
126 b: OneMillion,
127 c: 4,
128 d: Toronto,
129 e: 5
130 };
131
132 let packed_struct = PackedStruct {
133 a: 6,
134 b: OneHundred,
135 c: 7,
136 d: Vienna,
137 e: 8
138 };
139
140 let non_padded_struct = NonPaddedStruct {
141 a: OneMillion,
142 b: MountainView,
143 c: OneThousand,
144 d: Toronto
145 };
146
147 let struct_with_drop = (StructWithDrop { a: OneHundred, b: Vienna }, 9_i64);
148
149 zzz(); // #break
150 }
151
152 fn zzz() { () }