Skip to content

Commit c3000ad

Browse files
committed
add repr to the allowlist for naked functions, and test that it works
1 parent 739b1fd commit c3000ad

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

compiler/rustc_passes/src/check_attr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
516516
sym::no_mangle,
517517
sym::naked,
518518
sym::instruction_set,
519+
sym::repr,
519520
// code generation
520521
sym::cold,
521522
sym::target_feature,

tests/codegen/naked-fn/aligned.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ compile-flags: -C no-prepopulate-passes -Copt-level=0
2+
//@ needs-asm-support
3+
//@ ignore-arm no "ret" mnemonic
4+
5+
#![crate_type = "lib"]
6+
#![feature(naked_functions, fn_align)]
7+
use std::arch::asm;
8+
9+
// CHECK: Function Attrs: naked
10+
// CHECK-NEXT: define{{.*}}void @naked_empty()
11+
// CHECK: align 16
12+
#[repr(align(16))]
13+
#[no_mangle]
14+
#[naked]
15+
pub unsafe extern "C" fn naked_empty() {
16+
// CHECK-NEXT: start:
17+
// CHECK-NEXT: call void asm
18+
// CHECK-NEXT: unreachable
19+
asm!("ret", options(noreturn));
20+
}

0 commit comments

Comments
 (0)