-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate test file for invalid const operand
- Loading branch information
1 parent
74f711e
commit 08c8887
Showing
4 changed files
with
87 additions
and
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//@ needs-asm-support | ||
//@ ignore-nvptx64 | ||
//@ ignore-spirv | ||
|
||
#![feature(asm_const)] | ||
|
||
use std::arch::{asm, global_asm}; | ||
|
||
fn main() { | ||
unsafe { | ||
// Const operands must be integers and must be constants. | ||
|
||
asm!("{}", const 0); | ||
asm!("{}", const 0i32); | ||
asm!("{}", const 0i128); | ||
asm!("{}", const 0f32); | ||
//~^ ERROR invalid type for `const` operand | ||
asm!("{}", const 0 as *mut u8); | ||
//~^ ERROR invalid type for `const` operand | ||
asm!("{}", const &0); | ||
//~^ ERROR invalid type for `const` operand | ||
} | ||
} | ||
|
||
// Const operands must be integers and must be constants. | ||
|
||
global_asm!("{}", const 0); | ||
global_asm!("{}", const 0i32); | ||
global_asm!("{}", const 0i128); | ||
global_asm!("{}", const 0f32); | ||
//~^ ERROR invalid type for `const` operand | ||
global_asm!("{}", const 0 as *mut u8); | ||
//~^ ERROR invalid type for `const` operand |
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,52 @@ | ||
error: invalid type for `const` operand | ||
--> $DIR/invalid-const-operand.rs:16:20 | ||
| | ||
LL | asm!("{}", const 0f32); | ||
| ^^^^^^---- | ||
| | | ||
| is an `f32` | ||
| | ||
= help: `const` operands must be of an integer type | ||
|
||
error: invalid type for `const` operand | ||
--> $DIR/invalid-const-operand.rs:18:20 | ||
| | ||
LL | asm!("{}", const 0 as *mut u8); | ||
| ^^^^^^------------ | ||
| | | ||
| is a `*mut u8` | ||
| | ||
= help: `const` operands must be of an integer type | ||
|
||
error: invalid type for `const` operand | ||
--> $DIR/invalid-const-operand.rs:20:20 | ||
| | ||
LL | asm!("{}", const &0); | ||
| ^^^^^^-- | ||
| | | ||
| is a `&i32` | ||
| | ||
= help: `const` operands must be of an integer type | ||
|
||
error: invalid type for `const` operand | ||
--> $DIR/invalid-const-operand.rs:30:19 | ||
| | ||
LL | global_asm!("{}", const 0f32); | ||
| ^^^^^^---- | ||
| | | ||
| is an `f32` | ||
| | ||
= help: `const` operands must be of an integer type | ||
|
||
error: invalid type for `const` operand | ||
--> $DIR/invalid-const-operand.rs:32:19 | ||
| | ||
LL | global_asm!("{}", const 0 as *mut u8); | ||
| ^^^^^^------------ | ||
| | | ||
| is a `*mut u8` | ||
| | ||
= help: `const` operands must be of an integer type | ||
|
||
error: aborting due to 5 previous errors | ||
|
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