blob: f36e8454da99e252e4362fd40ee0ef21da7ddec3 [file] [log] [blame]
Michael Woerister99ebb812013-07-01 10:11:291// Copyright 2013 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// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12
13// compile-flags:-Z extra-debug-info
14// debugger:set print pretty off
15// debugger:break zzz
16// debugger:run
17// debugger:finish
18
19// debugger:print packed
20// check:$1 = {x = 123, y = 234, z = 345}
21
22// debugger:print packedInPacked
23// check:$2 = {a = 1111, b = {x = 2222, y = 3333, z = 4444}, c = 5555, d = {x = 6666, y = 7777, z = 8888}}
24
25// debugger:print packedInUnpacked
26// check:$3 = {a = -1111, b = {x = -2222, y = -3333, z = -4444}, c = -5555, d = {x = -6666, y = -7777, z = -8888}}
27
28// debugger:print unpackedInPacked
29// check:$4 = {a = 987, b = {x = 876, y = 765, z = 654}, c = {x = 543, y = 432, z = 321}, d = 210}
30
31
32// debugger:print packedInPackedWithDrop
33// check:$5 = {a = 11, b = {x = 22, y = 33, z = 44}, c = 55, d = {x = 66, y = 77, z = 88}}
34
35// debugger:print packedInUnpackedWithDrop
36// check:$6 = {a = -11, b = {x = -22, y = -33, z = -44}, c = -55, d = {x = -66, y = -77, z = -88}}
37
38// debugger:print unpackedInPackedWithDrop
39// check:$7 = {a = 98, b = {x = 87, y = 76, z = 65}, c = {x = 54, y = 43, z = 32}, d = 21}
40
41// debugger:print deeplyNested
42// check:$8 = {a = {a = 1, b = {x = 2, y = 3, z = 4}, c = 5, d = {x = 6, y = 7, z = 8}}, b = {a = 9, b = {x = 10, y = 11, z = 12}, c = {x = 13, y = 14, z = 15}, d = 16}, c = {a = 17, b = {x = 18, y = 19, z = 20}, c = 21, d = {x = 22, y = 23, z = 24}}, d = {a = 25, b = {x = 26, y = 27, z = 28}, c = 29, d = {x = 30, y = 31, z = 32}}, e = {a = 33, b = {x = 34, y = 35, z = 36}, c = {x = 37, y = 38, z = 39}, d = 40}, f = {a = 41, b = {x = 42, y = 43, z = 44}, c = 45, d = {x = 46, y = 47, z = 48}}}
43
Erick Tryzelaarad5c6762013-08-17 15:37:4244#[allow(unused_variable)];
45
Michael Woerister99ebb812013-07-01 10:11:2946#[packed]
47struct Packed {
48 x: i16,
49 y: i32,
50 z: i64
51}
52
53impl Drop for Packed {
54 fn drop(&self) {}
55}
56
57#[packed]
58struct PackedInPacked {
59 a: i32,
60 b: Packed,
61 c: i64,
62 d: Packed
63}
64
65struct PackedInUnpacked {
66 a: i32,
67 b: Packed,
68 c: i64,
69 d: Packed
70}
71
72struct Unpacked {
73 x: i64,
74 y: i32,
75 z: i16
76}
77
78impl Drop for Unpacked {
79 fn drop(&self) {}
80}
81
82#[packed]
83struct UnpackedInPacked {
84 a: i16,
85 b: Unpacked,
86 c: Unpacked,
87 d: i64
88}
89
90#[packed]
91struct PackedInPackedWithDrop {
92 a: i32,
93 b: Packed,
94 c: i64,
95 d: Packed
96}
97
98impl Drop for PackedInPackedWithDrop {
99 fn drop(&self) {}
100}
101
102struct PackedInUnpackedWithDrop {
103 a: i32,
104 b: Packed,
105 c: i64,
106 d: Packed
107}
108
109impl Drop for PackedInUnpackedWithDrop {
110 fn drop(&self) {}
111}
112
113#[packed]
114struct UnpackedInPackedWithDrop {
115 a: i16,
116 b: Unpacked,
117 c: Unpacked,
118 d: i64
119}
120
121impl Drop for UnpackedInPackedWithDrop {
122 fn drop(&self) {}
123}
124
125struct DeeplyNested {
126 a: PackedInPacked,
127 b: UnpackedInPackedWithDrop,
128 c: PackedInUnpacked,
129 d: PackedInUnpackedWithDrop,
130 e: UnpackedInPacked,
131 f: PackedInPackedWithDrop
132}
133
134fn main() {
135 let packed = Packed { x: 123, y: 234, z: 345 };
136
137 let packedInPacked = PackedInPacked {
138 a: 1111,
139 b: Packed { x: 2222, y: 3333, z: 4444 },
140 c: 5555,
141 d: Packed { x: 6666, y: 7777, z: 8888 }
142 };
143
144 let packedInUnpacked = PackedInUnpacked {
145 a: -1111,
146 b: Packed { x: -2222, y: -3333, z: -4444 },
147 c: -5555,
148 d: Packed { x: -6666, y: -7777, z: -8888 }
149 };
150
151 let unpackedInPacked = UnpackedInPacked {
152 a: 987,
153 b: Unpacked { x: 876, y: 765, z: 654 },
154 c: Unpacked { x: 543, y: 432, z: 321 },
155 d: 210
156 };
157
158 let packedInPackedWithDrop = PackedInPackedWithDrop {
159 a: 11,
160 b: Packed { x: 22, y: 33, z: 44 },
161 c: 55,
162 d: Packed { x: 66, y: 77, z: 88 }
163 };
164
165 let packedInUnpackedWithDrop = PackedInUnpackedWithDrop {
166 a: -11,
167 b: Packed { x: -22, y: -33, z: -44 },
168 c: -55,
169 d: Packed { x: -66, y: -77, z: -88 }
170 };
171
172 let unpackedInPackedWithDrop = UnpackedInPackedWithDrop {
173 a: 98,
174 b: Unpacked { x: 87, y: 76, z: 65 },
175 c: Unpacked { x: 54, y: 43, z: 32 },
176 d: 21
177 };
178
179 let deeplyNested = DeeplyNested {
180 a: PackedInPacked {
181 a: 1,
182 b: Packed { x: 2, y: 3, z: 4 },
183 c: 5,
184 d: Packed { x: 6, y: 7, z: 8 }
185 },
186 b: UnpackedInPackedWithDrop {
187 a: 9,
188 b: Unpacked { x: 10, y: 11, z: 12 },
189 c: Unpacked { x: 13, y: 14, z: 15 },
190 d: 16
191 },
192 c: PackedInUnpacked {
193 a: 17,
194 b: Packed { x: 18, y: 19, z: 20 },
195 c: 21,
196 d: Packed { x: 22, y: 23, z: 24 }
197 },
198 d: PackedInUnpackedWithDrop {
199 a: 25,
200 b: Packed { x: 26, y: 27, z: 28 },
201 c: 29,
202 d: Packed { x: 30, y: 31, z: 32 }
203 },
204 e: UnpackedInPacked {
205 a: 33,
206 b: Unpacked { x: 34, y: 35, z: 36 },
207 c: Unpacked { x: 37, y: 38, z: 39 },
208 d: 40
209 },
210 f: PackedInPackedWithDrop {
211 a: 41,
212 b: Packed { x: 42, y: 43, z: 44 },
213 c: 45,
214 d: Packed { x: 46, y: 47, z: 48 }
215 }
216 };
217
218 zzz();
219}
220
Erick Tryzelaarad5c6762013-08-17 15:37:42221fn zzz() {()}