File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags: -O -Ccodegen-units=1
2
+
3
+ #![ crate_type = "lib" ]
4
+
5
+ #[ repr( i64 ) ]
6
+ pub enum Boolean {
7
+ False = 0 ,
8
+ True = 1 ,
9
+ }
10
+
11
+ impl Clone for Boolean {
12
+ fn clone ( & self ) -> Self {
13
+ * self
14
+ }
15
+ }
16
+
17
+ impl Copy for Boolean { }
18
+
19
+ extern "C" {
20
+ fn set_value ( foo : * mut i64 ) ;
21
+ fn bar ( ) ;
22
+ }
23
+
24
+ pub fn foo ( x : bool ) {
25
+ let mut foo = core:: mem:: MaybeUninit :: < i64 > :: uninit ( ) ;
26
+ unsafe {
27
+ set_value ( foo. as_mut_ptr ( ) ) ;
28
+ }
29
+
30
+ if x {
31
+ let l1 = unsafe { * foo. as_mut_ptr ( ) . cast :: < Boolean > ( ) } ;
32
+ if matches ! ( l1, Boolean :: False ) {
33
+ unsafe {
34
+ * foo. as_mut_ptr ( ) = 0 ;
35
+ }
36
+ }
37
+ }
38
+
39
+ let l2 = unsafe { * foo. as_mut_ptr ( ) } ;
40
+ if l2 == 2 {
41
+ // CHECK: call void @bar
42
+ unsafe {
43
+ bar ( ) ;
44
+ }
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments