Skip to content

Commit e4e67bd

Browse files
committed
Add an attribute to mark function as unwinding
1 parent 90c48be commit e4e67bd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/librustc_trans/trans/attributes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub fn emit_uwtable(val: ValueRef, emit: bool) {
5959

6060
/// Tell LLVM whether the function can or cannot unwind.
6161
#[inline]
62-
#[allow(dead_code)] // possibly useful function
6362
pub fn unwind(val: ValueRef, can_unwind: bool) {
6463
if can_unwind {
6564
unsafe {
@@ -118,6 +117,8 @@ pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[hir::Attribute], llfn: ValueRe
118117
}
119118
} else if attr.check_name("allocator") {
120119
llvm::Attribute::NoAlias.apply_llfn(llvm::ReturnIndex as c_uint, llfn);
120+
} else if attr.check_name("unwind") {
121+
unwind(llfn, true);
121122
}
122123
}
123124
}

src/libsyntax/feature_gate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option<u32>, Status
188188

189189
// allow `extern "platform-intrinsic" { ... }`
190190
("platform_intrinsics", "1.4.0", Some(27731), Active),
191+
192+
// allow `#[unwind]`
193+
("unwind_attributes", "1.4.0", None, Active),
191194
];
192195
// (changing above list without updating src/doc/reference.md makes @cmr sad)
193196

@@ -316,6 +319,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
316319
("unsafe_no_drop_flag", Whitelisted, Gated("unsafe_no_drop_flag",
317320
"unsafe_no_drop_flag has unstable semantics \
318321
and may be removed in the future")),
322+
("unwind", Whitelisted, Gated("unwind_attributes", "#[unwind] is experimental")),
319323

320324
// used in resolve
321325
("prelude_import", Whitelisted, Gated("prelude_import",

0 commit comments

Comments
 (0)