about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBjörn Steinbrink <bsteinbr@gmail.com>2015-09-11 20:09:19 +0200
committerBjörn Steinbrink <bsteinbr@gmail.com>2015-09-13 23:42:40 +0200
commite4e67bd489934702e4958a03bb4c948919d38920 (patch)
tree8efcf2d638423c3e6bdd5268fe0bc0b9e69d28cc /src
parent90c48bed25751f4c171b1555f8114234ca0a81c4 (diff)
downloadrust-e4e67bd489934702e4958a03bb4c948919d38920.tar.gz
rust-e4e67bd489934702e4958a03bb4c948919d38920.zip
Add an attribute to mark function as unwinding
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/trans/attributes.rs3
-rw-r--r--src/libsyntax/feature_gate.rs4
2 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc_trans/trans/attributes.rs b/src/librustc_trans/trans/attributes.rs
index a1f4ed5c20d..c77cb491448 100644
--- a/src/librustc_trans/trans/attributes.rs
+++ b/src/librustc_trans/trans/attributes.rs
@@ -59,7 +59,6 @@ pub fn emit_uwtable(val: ValueRef, emit: bool) {
 
 /// Tell LLVM whether the function can or cannot unwind.
 #[inline]
-#[allow(dead_code)] // possibly useful function
 pub fn unwind(val: ValueRef, can_unwind: bool) {
     if can_unwind {
         unsafe {
@@ -118,6 +117,8 @@ pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[hir::Attribute], llfn: ValueRe
             }
         } else if attr.check_name("allocator") {
             llvm::Attribute::NoAlias.apply_llfn(llvm::ReturnIndex as c_uint, llfn);
+        } else if attr.check_name("unwind") {
+            unwind(llfn, true);
         }
     }
 }
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 47f24856303..abc04102950 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -188,6 +188,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option<u32>, Status
 
     // allow `extern "platform-intrinsic" { ... }`
     ("platform_intrinsics", "1.4.0", Some(27731), Active),
+
+    // allow `#[unwind]`
+    ("unwind_attributes", "1.4.0", None, Active),
 ];
 // (changing above list without updating src/doc/reference.md makes @cmr sad)
 
@@ -316,6 +319,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
     ("unsafe_no_drop_flag", Whitelisted, Gated("unsafe_no_drop_flag",
                                                "unsafe_no_drop_flag has unstable semantics \
                                                 and may be removed in the future")),
+    ("unwind", Whitelisted, Gated("unwind_attributes", "#[unwind] is experimental")),
 
     // used in resolve
     ("prelude_import", Whitelisted, Gated("prelude_import",