]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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 | ||
0bf4aa26 XL |
11 | // ignore-tidy-linelength |
12 | ||
c34b1796 | 13 | // ignore-aarch64 |
2c00a5a8 | 14 | // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 |
1a4d82fc JJ |
15 | // min-lldb-version: 310 |
16 | ||
17 | // compile-flags:-g | |
18 | ||
19 | // === GDB TESTS =================================================================================== | |
20 | ||
8bb4bdeb XL |
21 | // gdbg-command:print 'c_style_enum::SINGLE_VARIANT' |
22 | // gdbr-command:print c_style_enum::SINGLE_VARIANT | |
c30ab7b3 SL |
23 | // gdbg-check:$1 = TheOnlyVariant |
24 | // gdbr-check:$1 = c_style_enum::SingleVariant::TheOnlyVariant | |
1a4d82fc | 25 | |
8bb4bdeb XL |
26 | // gdbg-command:print 'c_style_enum::AUTO_ONE' |
27 | // gdbr-command:print c_style_enum::AUTO_ONE | |
c30ab7b3 SL |
28 | // gdbg-check:$2 = One |
29 | // gdbr-check:$2 = c_style_enum::AutoDiscriminant::One | |
1a4d82fc | 30 | |
8bb4bdeb XL |
31 | // gdbg-command:print 'c_style_enum::AUTO_TWO' |
32 | // gdbr-command:print c_style_enum::AUTO_TWO | |
c30ab7b3 SL |
33 | // gdbg-check:$3 = One |
34 | // gdbr-check:$3 = c_style_enum::AutoDiscriminant::One | |
1a4d82fc | 35 | |
8bb4bdeb XL |
36 | // gdbg-command:print 'c_style_enum::AUTO_THREE' |
37 | // gdbr-command:print c_style_enum::AUTO_THREE | |
c30ab7b3 SL |
38 | // gdbg-check:$4 = One |
39 | // gdbr-check:$4 = c_style_enum::AutoDiscriminant::One | |
1a4d82fc | 40 | |
8bb4bdeb XL |
41 | // gdbg-command:print 'c_style_enum::MANUAL_ONE' |
42 | // gdbr-command:print c_style_enum::MANUAL_ONE | |
c30ab7b3 SL |
43 | // gdbg-check:$5 = OneHundred |
44 | // gdbr-check:$5 = c_style_enum::ManualDiscriminant::OneHundred | |
1a4d82fc | 45 | |
8bb4bdeb XL |
46 | // gdbg-command:print 'c_style_enum::MANUAL_TWO' |
47 | // gdbr-command:print c_style_enum::MANUAL_TWO | |
c30ab7b3 SL |
48 | // gdbg-check:$6 = OneHundred |
49 | // gdbr-check:$6 = c_style_enum::ManualDiscriminant::OneHundred | |
1a4d82fc | 50 | |
8bb4bdeb XL |
51 | // gdbg-command:print 'c_style_enum::MANUAL_THREE' |
52 | // gdbr-command:print c_style_enum::MANUAL_THREE | |
c30ab7b3 SL |
53 | // gdbg-check:$7 = OneHundred |
54 | // gdbr-check:$7 = c_style_enum::ManualDiscriminant::OneHundred | |
1a4d82fc JJ |
55 | |
56 | // gdb-command:run | |
57 | ||
58 | // gdb-command:print auto_one | |
c30ab7b3 SL |
59 | // gdbg-check:$8 = One |
60 | // gdbr-check:$8 = c_style_enum::AutoDiscriminant::One | |
1a4d82fc JJ |
61 | |
62 | // gdb-command:print auto_two | |
c30ab7b3 SL |
63 | // gdbg-check:$9 = Two |
64 | // gdbr-check:$9 = c_style_enum::AutoDiscriminant::Two | |
1a4d82fc JJ |
65 | |
66 | // gdb-command:print auto_three | |
c30ab7b3 SL |
67 | // gdbg-check:$10 = Three |
68 | // gdbr-check:$10 = c_style_enum::AutoDiscriminant::Three | |
1a4d82fc JJ |
69 | |
70 | // gdb-command:print manual_one_hundred | |
c30ab7b3 SL |
71 | // gdbg-check:$11 = OneHundred |
72 | // gdbr-check:$11 = c_style_enum::ManualDiscriminant::OneHundred | |
1a4d82fc JJ |
73 | |
74 | // gdb-command:print manual_one_thousand | |
c30ab7b3 SL |
75 | // gdbg-check:$12 = OneThousand |
76 | // gdbr-check:$12 = c_style_enum::ManualDiscriminant::OneThousand | |
1a4d82fc JJ |
77 | |
78 | // gdb-command:print manual_one_million | |
c30ab7b3 SL |
79 | // gdbg-check:$13 = OneMillion |
80 | // gdbr-check:$13 = c_style_enum::ManualDiscriminant::OneMillion | |
1a4d82fc JJ |
81 | |
82 | // gdb-command:print single_variant | |
c30ab7b3 SL |
83 | // gdbg-check:$14 = TheOnlyVariant |
84 | // gdbr-check:$14 = c_style_enum::SingleVariant::TheOnlyVariant | |
85 | ||
86 | // gdbg-command:print 'c_style_enum::AUTO_TWO' | |
87 | // gdbr-command:print AUTO_TWO | |
88 | // gdbg-check:$15 = Two | |
89 | // gdbr-check:$15 = c_style_enum::AutoDiscriminant::Two | |
90 | ||
91 | // gdbg-command:print 'c_style_enum::AUTO_THREE' | |
92 | // gdbr-command:print AUTO_THREE | |
93 | // gdbg-check:$16 = Three | |
94 | // gdbr-check:$16 = c_style_enum::AutoDiscriminant::Three | |
95 | ||
96 | // gdbg-command:print 'c_style_enum::MANUAL_TWO' | |
97 | // gdbr-command:print MANUAL_TWO | |
98 | // gdbg-check:$17 = OneThousand | |
99 | // gdbr-check:$17 = c_style_enum::ManualDiscriminant::OneThousand | |
100 | ||
101 | // gdbg-command:print 'c_style_enum::MANUAL_THREE' | |
102 | // gdbr-command:print MANUAL_THREE | |
103 | // gdbg-check:$18 = OneMillion | |
104 | // gdbr-check:$18 = c_style_enum::ManualDiscriminant::OneMillion | |
1a4d82fc JJ |
105 | |
106 | ||
107 | // === LLDB TESTS ================================================================================== | |
108 | ||
109 | // lldb-command:run | |
110 | ||
111 | // lldb-command:print auto_one | |
0bf4aa26 XL |
112 | // lldbg-check:[...]$0 = One |
113 | // lldbr-check:(c_style_enum::AutoDiscriminant) auto_one = c_style_enum::AutoDiscriminant::One | |
1a4d82fc JJ |
114 | |
115 | // lldb-command:print auto_two | |
0bf4aa26 XL |
116 | // lldbg-check:[...]$1 = Two |
117 | // lldbr-check:(c_style_enum::AutoDiscriminant) auto_two = c_style_enum::AutoDiscriminant::Two | |
1a4d82fc JJ |
118 | |
119 | // lldb-command:print auto_three | |
0bf4aa26 XL |
120 | // lldbg-check:[...]$2 = Three |
121 | // lldbr-check:(c_style_enum::AutoDiscriminant) auto_three = c_style_enum::AutoDiscriminant::Three | |
1a4d82fc JJ |
122 | |
123 | // lldb-command:print manual_one_hundred | |
0bf4aa26 XL |
124 | // lldbg-check:[...]$3 = OneHundred |
125 | // lldbr-check:(c_style_enum::ManualDiscriminant) manual_one_hundred = c_style_enum::ManualDiscriminant::OneHundred | |
1a4d82fc JJ |
126 | |
127 | // lldb-command:print manual_one_thousand | |
0bf4aa26 XL |
128 | // lldbg-check:[...]$4 = OneThousand |
129 | // lldbr-check:(c_style_enum::ManualDiscriminant) manual_one_thousand = c_style_enum::ManualDiscriminant::OneThousand | |
1a4d82fc JJ |
130 | |
131 | // lldb-command:print manual_one_million | |
0bf4aa26 XL |
132 | // lldbg-check:[...]$5 = OneMillion |
133 | // lldbr-check:(c_style_enum::ManualDiscriminant) manual_one_million = c_style_enum::ManualDiscriminant::OneMillion | |
1a4d82fc JJ |
134 | |
135 | // lldb-command:print single_variant | |
0bf4aa26 XL |
136 | // lldbg-check:[...]$6 = TheOnlyVariant |
137 | // lldbr-check:(c_style_enum::SingleVariant) single_variant = c_style_enum::SingleVariant::TheOnlyVariant | |
1a4d82fc JJ |
138 | |
139 | #![allow(unused_variables)] | |
140 | #![allow(dead_code)] | |
b039eaaf | 141 | #![feature(omit_gdb_pretty_printer_section)] |
1a4d82fc JJ |
142 | #![omit_gdb_pretty_printer_section] |
143 | ||
144 | use self::AutoDiscriminant::{One, Two, Three}; | |
145 | use self::ManualDiscriminant::{OneHundred, OneThousand, OneMillion}; | |
146 | use self::SingleVariant::TheOnlyVariant; | |
147 | ||
c34b1796 | 148 | #[derive(Copy, Clone)] |
1a4d82fc JJ |
149 | enum AutoDiscriminant { |
150 | One, | |
151 | Two, | |
152 | Three | |
153 | } | |
154 | ||
c34b1796 | 155 | #[derive(Copy, Clone)] |
1a4d82fc JJ |
156 | enum ManualDiscriminant { |
157 | OneHundred = 100, | |
158 | OneThousand = 1000, | |
159 | OneMillion = 1000000 | |
160 | } | |
161 | ||
c34b1796 | 162 | #[derive(Copy, Clone)] |
83c7162d | 163 | #[repr(u8)] |
1a4d82fc JJ |
164 | enum SingleVariant { |
165 | TheOnlyVariant | |
166 | } | |
167 | ||
168 | static SINGLE_VARIANT: SingleVariant = TheOnlyVariant; | |
169 | ||
170 | static mut AUTO_ONE: AutoDiscriminant = One; | |
171 | static mut AUTO_TWO: AutoDiscriminant = One; | |
172 | static mut AUTO_THREE: AutoDiscriminant = One; | |
173 | ||
174 | static mut MANUAL_ONE: ManualDiscriminant = OneHundred; | |
175 | static mut MANUAL_TWO: ManualDiscriminant = OneHundred; | |
176 | static mut MANUAL_THREE: ManualDiscriminant = OneHundred; | |
177 | ||
178 | fn main() { | |
179 | ||
180 | let auto_one = One; | |
181 | let auto_two = Two; | |
182 | let auto_three = Three; | |
183 | ||
184 | let manual_one_hundred = OneHundred; | |
185 | let manual_one_thousand = OneThousand; | |
186 | let manual_one_million = OneMillion; | |
187 | ||
188 | let single_variant = TheOnlyVariant; | |
189 | ||
190 | unsafe { | |
191 | AUTO_TWO = Two; | |
192 | AUTO_THREE = Three; | |
193 | ||
194 | MANUAL_TWO = OneThousand; | |
195 | MANUAL_THREE = OneMillion; | |
196 | }; | |
197 | ||
198 | zzz(); // #break | |
199 | ||
a7813a04 XL |
200 | // Borrow to avoid an eager load of the constant value in the static. |
201 | let a = &SINGLE_VARIANT; | |
1a4d82fc JJ |
202 | let a = unsafe { AUTO_ONE }; |
203 | let a = unsafe { MANUAL_ONE }; | |
204 | } | |
205 | ||
206 | fn zzz() { () } |