Insure bools remain 0x1 or 0x0 by having boolean-NOT not just be a simple bit-NOT.

This commit is contained in:
Roy Frostig 2010-08-25 17:15:15 -07:00
parent 2c8ae5ca8d
commit 6b053f24c7
3 changed files with 20 additions and 1 deletions

View File

@ -440,6 +440,7 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
bind-thunk.rs \
bind-trivial.rs \
bitwise.rs \
bool-not.rs \
box-in-tup.rs \
box-unbox.rs \
cast.rs \

View File

@ -2058,7 +2058,10 @@ let trans_visitor
in
anno ();
emit (Il.unary op dst src);
Il.Cell dst
(* Insist the bool domain being 0x0 and 0x1 *)
if unop = Ast.UNOP_not
then trans_binary Ast.BINOP_and (Il.Cell dst) one
else Il.Cell dst
| Ast.EXPR_atom a ->
trans_atom a

View File

@ -0,0 +1,15 @@
// -*- rust -*-
fn main() {
if (!false) {
check (true);
} else {
check (false);
}
if (!true) {
check (false);
} else {
check (true);
}
}