From: ceriel Date: Fri, 4 Nov 1988 13:12:14 +0000 (+0000) Subject: Changed translation of FOR-statement: now, if it is executed 0 X-Git-Tag: release-5-5~2751 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b90690ba5d5d092cadab109e110d37c0e8bbf7dd;p=ack.git Changed translation of FOR-statement: now, if it is executed 0 times, the loop-control-variable is not assigned to --- diff --git a/lang/m2/comp/Version.c b/lang/m2/comp/Version.c index 6bebc5a7c..7fd93f6c4 100644 --- a/lang/m2/comp/Version.c +++ b/lang/m2/comp/Version.c @@ -1 +1 @@ -static char Version[] = "ACK Modula-2 compiler Version 0.41"; +static char Version[] = "ACK Modula-2 compiler Version 0.42"; diff --git a/lang/m2/comp/walk.c b/lang/m2/comp/walk.c index 472a849aa..28a52f83b 100644 --- a/lang/m2/comp/walk.c +++ b/lang/m2/comp/walk.c @@ -525,7 +525,7 @@ WalkStat(nd, exit_label) case FOR: { arith tmp = NewInt(); - arith tmp2 = 0; + arith tmp2 = NewInt(); register t_node *fnd; int good_forvar; label l1 = ++text_label; @@ -548,11 +548,13 @@ WalkStat(nd, exit_label) C_stl(tmp); CodePExpr(left->nd_left); C_dup(int_size); - CodeDStore(nd); + C_stl(tmp2); C_lol(tmp); if (uns) C_cmu(int_size); else C_cmi(int_size); C_zgt(l2); + C_lol(tmp2); + CodeDStore(nd); C_lol(tmp); ForLoopVarExpr(nd); if (left->nd_INT >= 0) { @@ -570,13 +572,12 @@ WalkStat(nd, exit_label) nd->nd_def->df_flags |= D_FORLOOP; def_ilb(l1); if (! options['R']) { - tmp2 = NewInt(); ForLoopVarExpr(nd); C_stl(tmp2); } WalkNode(right, exit_label); nd->nd_def->df_flags &= ~D_FORLOOP; - if (tmp2 != 0) { + if (! options['R']) { label x = ++text_label; C_lol(tmp2); ForLoopVarExpr(nd); @@ -584,8 +585,8 @@ WalkStat(nd, exit_label) c_loc(M2_FORCH); C_trp(); def_ilb(x); - FreeInt(tmp2); } + FreeInt(tmp2); if (stepsize) { C_lol(tmp); C_zeq(l2);