File tree 3 files changed +66
-36
lines changed
3 files changed +66
-36
lines changed Original file line number Diff line number Diff line change
1
+ // Ensure inout asm! operands are marked as used by the liveness pass
2
+
3
+ // check-pass
4
+
5
+ #![ feature( asm) ]
6
+ #![ allow( dead_code) ]
7
+ #![ warn( unused_assignments) ]
8
+ #![ warn( unused_variables) ]
9
+
10
+ // Test the single inout case
11
+ unsafe fn f1 ( mut src : * const u8 ) {
12
+ asm ! ( "/*{0}*/" , inout( reg) src) ; //~ WARN value assigned to `src` is never read
13
+ }
14
+
15
+ unsafe fn f2 ( mut src : * const u8 ) -> * const u8 {
16
+ asm ! ( "/*{0}*/" , inout( reg) src) ;
17
+ src
18
+ }
19
+
20
+ // Test the split inout case
21
+ unsafe fn f3 ( mut src : * const u8 ) {
22
+ asm ! ( "/*{0}*/" , inout( reg) src => src) ; //~ WARN value assigned to `src` is never read
23
+ }
24
+
25
+ unsafe fn f4 ( mut src : * const u8 ) -> * const u8 {
26
+ asm ! ( "/*{0}*/" , inout( reg) src => src) ;
27
+ src
28
+ }
29
+
30
+ // Tests the use of field projections
31
+ struct S {
32
+ field : * mut u8 ,
33
+ }
34
+
35
+ unsafe fn f5 ( src : & mut S ) {
36
+ asm ! ( "/*{0}*/" , inout( reg) src. field) ;
37
+ }
38
+
39
+ unsafe fn f6 ( src : & mut S ) {
40
+ asm ! ( "/*{0}*/" , inout( reg) src. field => src. field) ;
41
+ }
42
+
43
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ warning: value assigned to `src` is never read
2
+ --> $DIR/liveness-asm.rs:12:32
3
+ |
4
+ LL | asm!("/*{0}*/", inout(reg) src);
5
+ | ^^^
6
+ |
7
+ note: the lint level is defined here
8
+ --> $DIR/liveness-asm.rs:7:9
9
+ |
10
+ LL | #![warn(unused_assignments)]
11
+ | ^^^^^^^^^^^^^^^^^^
12
+ = help: maybe it is overwritten before being read?
13
+
14
+ warning: value assigned to `src` is never read
15
+ --> $DIR/liveness-asm.rs:22:39
16
+ |
17
+ LL | asm!("/*{0}*/", inout(reg) src => src);
18
+ | ^^^
19
+ |
20
+ = help: maybe it is overwritten before being read?
21
+
22
+ warning: 2 warnings emitted
23
+
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments