allow #[target_feature] on #[naked] functions

This commit is contained in:
Folkert 2024-07-23 16:02:32 +02:00
parent c6a166bac2
commit a3bb0104ff
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
5 changed files with 7 additions and 27 deletions

View File

@ -5,7 +5,6 @@ Notable attributes that are incompatible with `#[naked]` are:
* `#[inline]` * `#[inline]`
* `#[track_caller]` * `#[track_caller]`
* `#[target_feature]`
* `#[test]`, `#[ignore]`, `#[should_panic]` * `#[test]`, `#[ignore]`, `#[should_panic]`
Erroneous code example: Erroneous code example:

View File

@ -423,7 +423,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
// //
// * `#[inline]` // * `#[inline]`
// * `#[track_caller]` // * `#[track_caller]`
// * `#[target_feature]`
// * `#[test]`, `#[ignore]`, `#[should_panic]` // * `#[test]`, `#[ignore]`, `#[should_panic]`
// //
// NOTE: when making changes to this list, check that `error_codes/E0736.md` remains accurate // NOTE: when making changes to this list, check that `error_codes/E0736.md` remains accurate
@ -452,6 +451,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
sym::instruction_set, sym::instruction_set,
// code generation // code generation
sym::cold, sym::cold,
sym::target_feature,
// documentation // documentation
sym::doc, sym::doc,
]; ];

View File

@ -1,13 +0,0 @@
//@ only-x86_64
//@ needs-asm-support
#![feature(naked_functions)]
#![crate_type = "lib"]
use std::arch::asm;
#[target_feature(enable = "sse2")]
//~^ ERROR [E0736]
#[naked]
pub unsafe extern "C" fn naked_target_feature() {
asm!("", options(noreturn));
}

View File

@ -1,12 +0,0 @@
error[E0736]: attribute incompatible with `#[naked]`
--> $DIR/naked-functions-target-feature.rs:8:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `target_feature` attribute is incompatible with `#[naked]`
LL |
LL | #[naked]
| -------- function marked with `#[naked]` here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0736`.

View File

@ -231,6 +231,12 @@ pub unsafe extern "C" fn compatible_codegen_attributes() {
asm!("", options(noreturn, att_syntax)); asm!("", options(noreturn, att_syntax));
} }
#[target_feature(enable = "sse2")]
#[naked]
pub unsafe extern "C" fn compatible_target_feature() {
asm!("", options(noreturn));
}
#[doc = "foo bar baz"] #[doc = "foo bar baz"]
#[naked] #[naked]
pub unsafe extern "C" fn compatible_doc_attributes() { pub unsafe extern "C" fn compatible_doc_attributes() {