Skip to content

Commit c01e487

Browse files
committed
Un-XFAIL do-while-body-fails
Made it work both with optimization enabled, and with optimization disabled. Huzzah!
1 parent 60e1cea commit c01e487

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/comp/middle/trans.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3805,7 +3805,14 @@ fn trans_do_while(cx: &@block_ctxt, body: &ast::blk, cond: &@ast::expr) ->
38053805
if is_terminated(body_res.bcx) {
38063806
// This is kind of ridiculous, but no permutations
38073807
// involving body_res or body_cx.val worked.
3808-
ret trans_block(cx, body, return);
3808+
let rs = trans_block(cx, body, return);
3809+
if ! is_terminated (next_cx) {
3810+
next_cx.build.Unreachable();
3811+
}
3812+
if ! is_terminated (body_cx) {
3813+
body_cx.build.Unreachable();
3814+
}
3815+
ret rs;
38093816
}
38103817
let cond_res = trans_expr(body_res.bcx, cond);
38113818
cond_res.bcx.build.CondBr(cond_res.val, body_cx.llbb, next_cx.llbb);

src/test/run-fail/do-while-body-fails.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// xfail-stage1
2-
// xfail-stage2
3-
// xfail-stage3
41
// error-pattern:quux
52
fn main() {
63
let x: int = do { fail "quux" } while (true);

0 commit comments

Comments
 (0)