File tree 1 file changed +50
-0
lines changed
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags: -O -Ccodegen-units=1
2
+ // only-x86_64-unknown-linux-gnu
3
+
4
+ #![ crate_type = "lib" ]
5
+
6
+ #[ repr( i64 ) ]
7
+ pub enum Boolean {
8
+ False = 0 ,
9
+ True = 1 ,
10
+ }
11
+
12
+ impl Clone for Boolean {
13
+ fn clone ( & self ) -> Self {
14
+ * self
15
+ }
16
+ }
17
+
18
+ impl Copy for Boolean { }
19
+
20
+ extern "C" {
21
+ fn set_value ( foo : * mut i64 ) ;
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
+ bar ( ) ;
43
+ }
44
+ }
45
+
46
+ #[ no_mangle]
47
+ #[ inline( never) ]
48
+ pub fn bar ( ) {
49
+ println ! ( "Working correctly!" ) ;
50
+ }
You can’t perform that action at this time.
0 commit comments