Skip to content

Commit 8f0bced

Browse files
committed
Refactor liveness-issue-77915 to liveness-asm and improve tests
1 parent 17c6c59 commit 8f0bced

File tree

3 files changed

+66
-36
lines changed

3 files changed

+66
-36
lines changed

src/test/ui/liveness/liveness-asm.rs

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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() {}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+

src/test/ui/liveness/liveness-issue-77915.rs

-36
This file was deleted.

0 commit comments

Comments
 (0)