]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/by-value-non-immediate-argument.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / debuginfo / by-value-non-immediate-argument.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 s
21 // gdb-check:$1 = {a = 1, b = 2.5}
22 // gdb-command:continue
23
24 // gdb-command:print x
25 // gdb-check:$2 = {a = 3, b = 4.5}
26 // gdb-command:print y
27 // gdb-check:$3 = 5
28 // gdb-command:print z
29 // gdb-check:$4 = 6.5
30 // gdb-command:continue
31
32 // gdb-command:print a
33 // gdb-check:$5 = {__0 = 7, __1 = 8, __2 = 9.5, __3 = 10.5}
34 // gdb-command:continue
35
36 // gdb-command:print a
37 // gdb-check:$6 = {__0 = 11.5, __1 = 12.5, __2 = 13, __3 = 14}
38 // gdb-command:continue
39
40 // gdb-command:print x
41 // gdb-check:$7 = {{RUST$ENUM$DISR = Case1, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = Case1, __0 = 0, __1 = 2088533116, __2 = 2088533116}}
42 // gdb-command:continue
43
44
45 // === LLDB TESTS ==================================================================================
46
47 // lldb-command:run
48
49 // lldb-command:print s
50 // lldb-check:[...]$0 = Struct { a: 1, b: 2.5 }
51 // lldb-command:continue
52
53 // lldb-command:print x
54 // lldb-check:[...]$1 = Struct { a: 3, b: 4.5 }
55 // lldb-command:print y
56 // lldb-check:[...]$2 = 5
57 // lldb-command:print z
58 // lldb-check:[...]$3 = 6.5
59 // lldb-command:continue
60
61 // lldb-command:print a
62 // lldb-check:[...]$4 = (7, 8, 9.5, 10.5)
63 // lldb-command:continue
64
65 // lldb-command:print a
66 // lldb-check:[...]$5 = Newtype(11.5, 12.5, 13, 14)
67 // lldb-command:continue
68
69 // lldb-command:print x
70 // lldb-check:[...]$6 = Case1 { x: 0, y: 8970181431921507452 }
71 // lldb-command:continue
72
73 #![feature(omit_gdb_pretty_printer_section)]
74 #![omit_gdb_pretty_printer_section]
75
76 #[derive(Clone)]
77 struct Struct {
78     a: isize,
79     b: f64
80 }
81
82 #[derive(Clone)]
83 struct StructStruct {
84     a: Struct,
85     b: Struct
86 }
87
88 fn fun(s: Struct) {
89     zzz(); // #break
90 }
91
92 fn fun_fun(StructStruct { a: x, b: Struct { a: y, b: z } }: StructStruct) {
93     zzz(); // #break
94 }
95
96 fn tup(a: (isize, usize, f64, f64)) {
97     zzz(); // #break
98 }
99
100 struct Newtype(f64, f64, isize, usize);
101
102 fn new_type(a: Newtype) {
103     zzz(); // #break
104 }
105
106 // The first element is to ensure proper alignment, irrespective of the machines word size. Since
107 // the size of the discriminant value is machine dependent, this has be taken into account when
108 // datatype layout should be predictable as in this case.
109 enum Enum {
110     Case1 { x: i64, y: i64 },
111     Case2 (i64, i32, i32),
112 }
113
114 fn by_val_enum(x: Enum) {
115     zzz(); // #break
116 }
117
118 fn main() {
119     fun(Struct { a: 1, b: 2.5 });
120     fun_fun(StructStruct { a: Struct { a: 3, b: 4.5 }, b: Struct { a: 5, b: 6.5 } });
121     tup((7, 8, 9.5, 10.5));
122     new_type(Newtype(11.5, 12.5, 13, 14));
123
124     // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
125     // 0b01111100011111000111110001111100 = 2088533116
126     // 0b0111110001111100 = 31868
127     // 0b01111100 = 124
128     by_val_enum(Enum::Case1 { x: 0, y: 8970181431921507452 });
129 }
130
131 fn zzz() { () }