]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #14643 : jakub-/rust/infinite-loop-unreachable, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 5 Jun 2014 13:46:54 +0000 (06:46 -0700)
committerbors <bors@rust-lang.org>
Thu, 5 Jun 2014 13:46:54 +0000 (06:46 -0700)
src/librustc/middle/trans/callee.rs
src/librustc/middle/trans/controlflow.rs
src/test/run-pass/issue-13352.rs [new file with mode: 0644]

index 1659ecaecd89cf325283ed33c2f8b92cac07f2db..b5cf3fb8e736d6db58464fad235ff037ad32abb3 100644 (file)
@@ -802,7 +802,7 @@ pub fn trans_arg_datum<'a>(
         // "undef" value, as such a value should never
         // be inspected. It's important for the value
         // to have type lldestty (the callee's expected type).
-        let llformal_arg_ty = type_of::type_of(ccx, formal_arg_ty);
+        let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, formal_arg_ty);
         unsafe {
             val = llvm::LLVMGetUndef(llformal_arg_ty.to_ref());
         }
index 2174fe3df9a078481bd78147884cc2fef39784b9..eac7af56ed4c00bd371c181273500e4c30fa0e54 100644 (file)
@@ -264,6 +264,10 @@ pub fn trans_loop<'a>(bcx:&'a Block<'a>,
 
     fcx.pop_loop_cleanup_scope(loop_id);
 
+    if ty::type_is_bot(node_id_type(bcx, loop_id)) {
+        Unreachable(next_bcx_in);
+    }
+
     return next_bcx_in;
 }
 
diff --git a/src/test/run-pass/issue-13352.rs b/src/test/run-pass/issue-13352.rs
new file mode 100644 (file)
index 0000000..f047781
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+extern crate libc;
+
+fn foo(_: proc()) {}
+
+fn main() {
+    foo(loop {
+        unsafe { libc::exit(0 as libc::c_int); }
+    });
+    2u + (loop {});
+    -(loop {});
+}