-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ui tests for repr align on functions; also with naked present, an…
…d update diagnostics
- Loading branch information
1 parent
3c71124
commit 87beb43
Showing
5 changed files
with
210 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//@ needs-asm-support | ||
#![feature(naked_functions)] | ||
#![feature(fn_align)] | ||
#![crate_type = "lib"] | ||
use std::arch::asm; | ||
|
||
#[repr(C)] | ||
//~^ ERROR attribute should be applied to a struct, enum, or union [E0517] | ||
//~| NOTE `#[repr(align(...))]` is valid on functions | ||
#[naked] | ||
extern "C" fn example1() { | ||
//~^ NOTE not a struct, enum, or union | ||
unsafe { asm!("", options(noreturn)) } | ||
} | ||
|
||
#[repr(transparent)] | ||
//~^ ERROR attribute should be applied to a struct, enum, or union [E0517] | ||
//~| NOTE `#[repr(align(...))]` is valid on functions | ||
#[naked] | ||
extern "C" fn example2() { | ||
//~^ NOTE not a struct, enum, or union | ||
unsafe { asm!("", options(noreturn)) } | ||
} | ||
|
||
#[repr(align(16), C)] | ||
//~^ ERROR attribute should be applied to a struct, enum, or union [E0517] | ||
//~| NOTE `#[repr(align(...))]` alone is valid on functions | ||
#[naked] | ||
extern "C" fn example3() { | ||
//~^ NOTE not a struct, enum, or union | ||
unsafe { asm!("", options(noreturn)) } | ||
} | ||
|
||
// note: two errors because of packed and C | ||
#[repr(C, packed)] | ||
//~^ ERROR attribute should be applied to a struct or union [E0517] | ||
//~| ERROR attribute should be applied to a struct, enum, or union [E0517] | ||
//~| NOTE `#[repr(align(...))]` is valid on functions | ||
//~| NOTE `#[repr(align(...))]` is valid on functions | ||
#[naked] | ||
extern "C" fn example4() { | ||
//~^ NOTE not a struct, enum, or union | ||
//~| NOTE not a struct or union | ||
unsafe { asm!("", options(noreturn)) } | ||
} | ||
|
||
#[repr(u8)] | ||
//~^ ERROR attribute should be applied to an enum [E0517] | ||
//~| NOTE `#[repr(align(...))]` is valid on functions | ||
#[naked] | ||
extern "C" fn example5() { | ||
//~^ NOTE not an enum | ||
unsafe { asm!("", options(noreturn)) } | ||
} |
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,93 @@ | ||
error[E0517]: attribute should be applied to a struct, enum, or union | ||
--> $DIR/naked-with-invalid-repr-attr.rs:7:8 | ||
| | ||
LL | #[repr(C)] | ||
| ^ | ||
... | ||
LL | / extern "C" fn example1() { | ||
LL | | | ||
LL | | unsafe { asm!("", options(noreturn)) } | ||
LL | | } | ||
| |_- not a struct, enum, or union | ||
| | ||
= note: `#[repr(align(...))]` is valid on functions | ||
|
||
error[E0517]: attribute should be applied to a struct, enum, or union | ||
--> $DIR/naked-with-invalid-repr-attr.rs:16:8 | ||
| | ||
LL | #[repr(transparent)] | ||
| ^^^^^^^^^^^ | ||
... | ||
LL | / extern "C" fn example2() { | ||
LL | | | ||
LL | | unsafe { asm!("", options(noreturn)) } | ||
LL | | } | ||
| |_- not a struct, enum, or union | ||
| | ||
= note: `#[repr(align(...))]` is valid on functions | ||
|
||
error[E0517]: attribute should be applied to a struct, enum, or union | ||
--> $DIR/naked-with-invalid-repr-attr.rs:25:19 | ||
| | ||
LL | #[repr(align(16), C)] | ||
| ^ | ||
... | ||
LL | / extern "C" fn example3() { | ||
LL | | | ||
LL | | unsafe { asm!("", options(noreturn)) } | ||
LL | | } | ||
| |_- not a struct, enum, or union | ||
| | ||
note: `#[repr(align(...))]` alone is valid on functions | ||
--> $DIR/naked-with-invalid-repr-attr.rs:25:8 | ||
| | ||
LL | #[repr(align(16), C)] | ||
| ^^^^^^^^^ | ||
|
||
error[E0517]: attribute should be applied to a struct, enum, or union | ||
--> $DIR/naked-with-invalid-repr-attr.rs:35:8 | ||
| | ||
LL | #[repr(C, packed)] | ||
| ^ | ||
... | ||
LL | / extern "C" fn example4() { | ||
LL | | | ||
LL | | | ||
LL | | unsafe { asm!("", options(noreturn)) } | ||
LL | | } | ||
| |_- not a struct, enum, or union | ||
| | ||
= note: `#[repr(align(...))]` is valid on functions | ||
|
||
error[E0517]: attribute should be applied to a struct or union | ||
--> $DIR/naked-with-invalid-repr-attr.rs:35:11 | ||
| | ||
LL | #[repr(C, packed)] | ||
| ^^^^^^ | ||
... | ||
LL | / extern "C" fn example4() { | ||
LL | | | ||
LL | | | ||
LL | | unsafe { asm!("", options(noreturn)) } | ||
LL | | } | ||
| |_- not a struct or union | ||
| | ||
= note: `#[repr(align(...))]` is valid on functions | ||
|
||
error[E0517]: attribute should be applied to an enum | ||
--> $DIR/naked-with-invalid-repr-attr.rs:47:8 | ||
| | ||
LL | #[repr(u8)] | ||
| ^^ | ||
... | ||
LL | / extern "C" fn example5() { | ||
LL | | | ||
LL | | unsafe { asm!("", options(noreturn)) } | ||
LL | | } | ||
| |_- not an enum | ||
| | ||
= note: `#[repr(align(...))]` is valid on functions | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0517`. |