Handle _|_ - typed things in the bodies of do-while loops
The resulting code is strange, but perhaps someone else can fix it. The obvious things, like returning body_res, all resulted in completely incomprehensible LLVM errors. Closes #814
This commit is contained in:
parent
19bbd02049
commit
051b401051
2 changed files with 9 additions and 0 deletions
|
@ -3802,6 +3802,11 @@ fn trans_do_while(cx: &@block_ctxt, body: &ast::blk, cond: &@ast::expr) ->
|
|||
new_loop_scope_block_ctxt(cx, option::none[@block_ctxt], next_cx,
|
||||
"do-while loop body");
|
||||
let body_res = trans_block(body_cx, body, return);
|
||||
if is_terminated(body_res.bcx) {
|
||||
// This is kind of ridiculous, but no permutations
|
||||
// involving body_res or body_cx.val worked.
|
||||
ret trans_block(cx, body, return);
|
||||
}
|
||||
let cond_res = trans_expr(body_res.bcx, cond);
|
||||
cond_res.bcx.build.CondBr(cond_res.val, body_cx.llbb, next_cx.llbb);
|
||||
cx.build.Br(body_cx.llbb);
|
||||
|
|
4
src/test/run-fail/do-while-body-fails.rs
Normal file
4
src/test/run-fail/do-while-body-fails.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
// error-pattern:quux
|
||||
fn main() {
|
||||
let x: int = do { fail "quux" } while (true);
|
||||
}
|
Loading…
Reference in a new issue