about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-09-25 04:40:45 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-09-25 04:45:29 -0400
commite76bfae7eb4405091625b973f1fbe1e8859afb15 (patch)
tree1d17f3b263d8e814c6c3ec9398db082a9905b9b1
parent893ba18cd16ca5922f827e38291de809915fca57 (diff)
add `noreturn` attribute to functions returning !
Closes #9317
-rw-r--r--src/librustc/middle/trans/base.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index 49b4d711f86..822f9e32d93 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -220,6 +220,12 @@ pub fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
     let llfn = decl_cdecl_fn(ccx.llmod, name, llfty);
 
     match ty::get(output).sty {
+        // functions returning bottom may unwind, but can never return normally
+        ty::ty_bot => {
+            unsafe {
+                llvm::LLVMAddFunctionAttr(llfn, lib::llvm::NoReturnAttribute as c_uint)
+            }
+        }
         // `~` pointer return values never alias because ownership is transferred
         ty::ty_uniq(*) |
         ty::ty_evec(_, ty::vstore_uniq) => {