-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add lint for inline asm labels that look like binary
- Loading branch information
1 parent
c1b336c
commit b00d875
Showing
8 changed files
with
391 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//@ needs-asm-support | ||
//@ only-x86_64 | ||
|
||
// tests that labels containing only the digits 0 and 1 are rejected | ||
// uses of such labels can sometimes be interpreted as a binary literal | ||
|
||
use std::arch::{asm, global_asm}; | ||
|
||
fn main() { | ||
unsafe { | ||
asm!("0: jmp 0b"); //~ ERROR avoid using labels containing only the digits | ||
asm!("1: jmp 1b"); //~ ERROR avoid using labels containing only the digits | ||
asm!("10: jmp 10b"); //~ ERROR avoid using labels containing only the digits | ||
asm!("01: jmp 01b"); //~ ERROR avoid using labels containing only the digits | ||
asm!("1001101: jmp 1001101b"); //~ ERROR avoid using labels containing only the digits | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
error: avoid using labels containing only the digits 0 and 1 in inline assembly | ||
--> $DIR/binary_asm_labels.rs:11:15 | ||
| | ||
LL | asm!("0: jmp 0b"); | ||
| ^ | ||
| | ||
= help: use a different number that has at least one digit 2 or greater | ||
= note: an LLVM bug makes these labels ambiguous with a binary literal number | ||
= note: `#[deny(binary_asm_labels)]` on by default | ||
|
||
error: avoid using labels containing only the digits 0 and 1 in inline assembly | ||
--> $DIR/binary_asm_labels.rs:12:15 | ||
| | ||
LL | asm!("1: jmp 1b"); | ||
| ^ | ||
| | ||
= help: use a different number that has at least one digit 2 or greater | ||
= note: an LLVM bug makes these labels ambiguous with a binary literal number | ||
|
||
error: avoid using labels containing only the digits 0 and 1 in inline assembly | ||
--> $DIR/binary_asm_labels.rs:13:15 | ||
| | ||
LL | asm!("10: jmp 10b"); | ||
| ^^ | ||
| | ||
= help: use a different number that has at least one digit 2 or greater | ||
= note: an LLVM bug makes these labels ambiguous with a binary literal number | ||
|
||
error: avoid using labels containing only the digits 0 and 1 in inline assembly | ||
--> $DIR/binary_asm_labels.rs:14:15 | ||
| | ||
LL | asm!("01: jmp 01b"); | ||
| ^^ | ||
| | ||
= help: use a different number that has at least one digit 2 or greater | ||
= note: an LLVM bug makes these labels ambiguous with a binary literal number | ||
|
||
error: avoid using labels containing only the digits 0 and 1 in inline assembly | ||
--> $DIR/binary_asm_labels.rs:15:15 | ||
| | ||
LL | asm!("1001101: jmp 1001101b"); | ||
| ^^^^^^^ | ||
| | ||
= help: use a different number that has at least one digit 2 or greater | ||
= note: an LLVM bug makes these labels ambiguous with a binary literal number | ||
|
||
error: aborting due to 5 previous errors | ||
|
Oops, something went wrong.