diff options
author | Kamil Dudka <kdudka@redhat.com> | 2009-07-18 21:34:10 +0000 |
---|---|---|
committer | Christopher Li <sparse@chrisli.org> | 2009-07-22 18:51:18 +0000 |
commit | f9dc98af0c575ec16c45fc95ac68fbefe46e75fb (patch) | |
tree | fa747320ba7747b925edb3bae649d0b154999352 | |
parent | 6298fb4d7325cf6967f4ff298472e5da8e129350 (diff) | |
download | sparse-f9dc98af0c575ec16c45fc95ac68fbefe46e75fb.tar.gz |
compile-i386: do not generate an infinite loop
I've probably encountered a bug within compile-i386.c. It generates
an infinite loop for 'while' statement. My testing example and proposed
patch are enclosed.
Kamil
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r-- | compile-i386.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compile-i386.c b/compile-i386.c index 37ea52ee..abe93131 100644 --- a/compile-i386.c +++ b/compile-i386.c @@ -1913,6 +1913,10 @@ static void emit_loop(struct statement *stmt) x86_symbol_decl(stmt->iterator_syms); x86_statement(pre_statement); + if (!post_condition || post_condition->type != EXPR_VALUE || post_condition->value) { + loop_top = new_label(); + emit_label(loop_top, "loop top"); + } if (pre_condition) { if (pre_condition->type == EXPR_VALUE) { if (!pre_condition->value) { @@ -1936,10 +1940,6 @@ static void emit_loop(struct statement *stmt) insn("jz", lbv, NULL, NULL); } } - if (!post_condition || post_condition->type != EXPR_VALUE || post_condition->value) { - loop_top = new_label(); - emit_label(loop_top, "loop top"); - } x86_statement(statement); if (stmt->iterator_continue->used) emit_label(loop_continue, "'continue' iterator"); |