]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/union-smoke.rs
Stabilize unions with `Copy` fields and no destructor
[rust.git] / src / test / debuginfo / union-smoke.rs
1 // Copyright 2016 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 // min-lldb-version: 310
12 // ignore-gdb-version: 7.11.90 - 7.12.9
13
14 // compile-flags:-g
15
16 // === GDB TESTS ===================================================================================
17
18 // gdb-command:run
19 // gdb-command:print u
20 // gdbg-check:$1 = {a = {__0 = 2 '\002', __1 = 2 '\002'}, b = 514}
21 // gdbr-check:$1 = union_smoke::U {a: (2, 2), b: 514}
22 // gdb-command:print union_smoke::SU
23 // gdbg-check:$2 = {a = {__0 = 1 '\001', __1 = 1 '\001'}, b = 257}
24 // gdbr-check:$2 = union_smoke::U {a: (1, 1), b: 257}
25
26 // === LLDB TESTS ==================================================================================
27
28 // lldb-command:run
29 // lldb-command:print u
30 // lldb-check:[...]$0 = U { a: ('\x02', '\x02'), b: 514 }
31 // lldb-command:print union_smoke::SU
32 // lldb-check:[...]$1 = U { a: ('\x01', '\x01'), b: 257 }
33
34 #![allow(unused)]
35 #![feature(omit_gdb_pretty_printer_section)]
36 #![omit_gdb_pretty_printer_section]
37
38 union U {
39     a: (u8, u8),
40     b: u16,
41 }
42
43 static mut SU: U = U { a: (1, 1) };
44
45 fn main() {
46     let u = U { b: (2 << 8) + 2 };
47     unsafe { SU = U { a: (1, 1) } }
48
49     zzz(); // #break
50 }
51
52 fn zzz() {()}