Skip to content

Commit 2214932

Browse files
committed
fix and test attribute on extern declarations and functions
1 parent de5c8d9 commit 2214932

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/librustc_codegen_llvm/attributes.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,7 @@ pub fn from_fn_attrs(
271271
false
272272
} else if let Some(id) = id {
273273
let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
274-
if cx.tcx.is_foreign_item(id) {
275-
// Foreign items like `extern "C" { fn foo(); }` and `extern "Rust" { fn bar(); }`
276-
// are assumed not to unwind.
277-
false
278-
} else if cx.tcx.abort_on_panic_shim(id, sig.abi) {
274+
if cx.tcx.abort_on_panic_shim(id, sig.abi) {
279275
// Since we are adding a shim to abort on panic, this cannot unwind.
280276
false
281277
} else {

src/test/codegen/extern-functions.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
#![feature(unwind_attributes)]
55

66
extern {
7-
// CHECK: Function Attrs: nounwind
8-
// CHECK-NEXT: declare void @extern_fn
9-
fn extern_fn(); // assumed not to unwind
7+
// CHECK-NOT: nounwind
8+
// CHECK: declare void @extern_fn
9+
fn extern_fn();
1010
// CHECK-NOT: nounwind
1111
// CHECK: declare void @unwinding_extern_fn
1212
#[unwind(allowed)]
1313
fn unwinding_extern_fn();
14-
// CHECK-NOT: nounwind
15-
// CHECK: declare void @aborting_extern_fn
14+
// CHECK: Function Attrs: nounwind
15+
// CHECK-NEXT: declare void @aborting_extern_fn
1616
#[unwind(aborts)]
17-
fn aborting_extern_fn(); // FIXME: we don't have the attribute here
17+
fn aborting_extern_fn();
1818
}
1919

2020
extern "Rust" {
@@ -25,10 +25,10 @@ extern "Rust" {
2525
// CHECK: declare void @rust_unwinding_extern_fn
2626
#[unwind(allowed)]
2727
fn rust_unwinding_extern_fn();
28-
// CHECK-NOT: nounwind
29-
// CHECK: declare void @rust_aborting_extern_fn
28+
// CHECK: Function Attrs: nounwind
29+
// CHECK-NEXT: declare void @rust_aborting_extern_fn
3030
#[unwind(aborts)]
31-
fn rust_aborting_extern_fn(); // FIXME: we don't have the attribute here
31+
fn rust_aborting_extern_fn();
3232
}
3333

3434
pub unsafe fn force_declare() {

0 commit comments

Comments
 (0)