Skip to content

Commit ab78013

Browse files
committed
---
yaml --- r: 4365 b: refs/heads/master c: 7c34550 h: refs/heads/master i: 4363: 77d3b94 v: v3
1 parent 4dd5b4d commit ab78013

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 44c93b5fb29dd8819946d7012414a6eed65ba365
2+
refs/heads/master: 7c34550931a457dd830173fc4a3c467a2ba2e784

trunk/src/comp/middle/trans.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,8 +2702,6 @@ fn trans_unary(cx: &@block_ctxt, op: ast::unop, e: &@ast::expr,
27022702
}
27032703
}
27042704

2705-
// Important to get types for both lhs and rhs, because one might be _|_
2706-
// and the other not.
27072705
fn trans_compare(cx0: &@block_ctxt, op: ast::binop,
27082706
lhs0: ValueRef, lhs_t: ty::t, rhs0: ValueRef,
27092707
rhs_t: ty::t) -> result {
@@ -2725,22 +2723,14 @@ fn trans_compare(cx0: &@block_ctxt, op: ast::binop,
27252723
ast::le. | ast::gt. { llop = C_u8(abi::cmp_glue_op_le); }
27262724
}
27272725

2728-
if (! ty::type_is_bot(bcx_tcx(cx0), rhs_r.ty) &&
2729-
! ty::type_is_bot(bcx_tcx(cx0), lhs_r.ty)) {
2730-
let rs = compare(cx, lhs, rhs, rhs_r.ty, llop);
2726+
let rs = compare(cx, lhs, rhs, rhs_r.ty, llop);
27312727

2732-
// Invert the result if necessary.
2733-
alt op {
2734-
ast::eq. | ast::lt. | ast::le. { ret rslt(rs.bcx, rs.val); }
2735-
ast::ne. | ast::ge. | ast::gt. {
2736-
ret rslt(rs.bcx, rs.bcx.build.Not(rs.val));
2737-
}
2738-
}
2739-
}
2740-
else {
2741-
// If either is bottom, it diverges. So no need to do the
2742-
// actual comparison.
2743-
ret rslt(cx, cx.build.Unreachable());
2728+
// Invert the result if necessary.
2729+
alt op {
2730+
ast::eq. | ast::lt. | ast::le. { ret rslt(rs.bcx, rs.val); }
2731+
ast::ne. | ast::ge. | ast::gt. {
2732+
ret rslt(rs.bcx, rs.bcx.build.Not(rs.val));
2733+
}
27442734
}
27452735
}
27462736

@@ -3387,6 +3377,14 @@ fn trans_vec_add(cx: &@block_ctxt, t: &ty::t, lhs: ValueRef, rhs: ValueRef) ->
33873377
// and the other not.
33883378
fn trans_eager_binop(cx: &@block_ctxt, op: ast::binop, lhs: ValueRef,
33893379
lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> result {
3380+
3381+
// If either is bottom, it diverges. So no need to do the
3382+
// operation.
3383+
if (ty::type_is_bot(bcx_tcx(cx), lhs_t) ||
3384+
ty::type_is_bot(bcx_tcx(cx), rhs_t)) {
3385+
ret rslt(cx, cx.build.Unreachable());
3386+
}
3387+
33903388
let is_float = false;
33913389
let intype = lhs_t;
33923390
if ty::type_is_bot(bcx_tcx(cx), intype) {

trunk/src/comp/middle/ty.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,7 @@ fn is_binopable(cx: &ctxt, ty: t, op: ast::binop) -> bool {
28802880
const tycat_str: int = 4;
28812881
const tycat_vec: int = 5;
28822882
const tycat_struct: int = 6;
2883+
const tycat_bot: int = 7;
28832884

28842885
const opcat_add: int = 0;
28852886
const opcat_sub: int = 1;
@@ -2938,6 +2939,7 @@ fn is_binopable(cx: &ctxt, ty: t, op: ast::binop) -> bool {
29382939
ty_ivec(_) { tycat_vec }
29392940
ty_rec(_) { tycat_struct }
29402941
ty_tag(_, _) { tycat_struct }
2942+
ty_bot. { tycat_bot }
29412943
_ { tycat_other }
29422944
}
29432945
}
@@ -2954,11 +2956,13 @@ fn is_binopable(cx: &ctxt, ty: t, op: ast::binop) -> bool {
29542956
/*float*/
29552957
/*str*/
29562958
/*vec*/
2959+
/*bot*/
29572960
tbl =
29582961
[[f, f, f, f, t, t, f, f], [f, f, f, f, t, t, t, t],
29592962
[t, t, t, t, t, t, t, f], [t, t, t, f, t, t, f, f],
29602963
[t, f, f, f, t, t, f, f], [t, f, f, f, t, t, f, f],
2961-
[f, f, f, f, t, t, f, f]]; /*struct*/
2964+
[f, f, f, f, t, t, f, f],
2965+
[t, t, t, t, t, t, t, t]]; /*struct*/
29622966

29632967
ret tbl.(tycat(cx, ty)).(opcat(op));
29642968
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn wsucc(n: int) -> int {
2+
{ ret n + 1 } + 0;
3+
}
4+
fn main() {}

0 commit comments

Comments
 (0)