From 65f3bb6751dff212c78d67f2deee6602898873e9 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 27 Jun 2013 15:12:18 +0300 Subject: Minor cleanup in awkgram.y. --- awkgram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'awkgram.c') diff --git a/awkgram.c b/awkgram.c index 10fd4215..947f4a30 100644 --- a/awkgram.c +++ b/awkgram.c @@ -2603,7 +2603,7 @@ yyreduce: (yyval) = list_prepend(ip, (yyvsp[(1) - (8)])); bcfree((yyvsp[(4) - (8)])); } /* else - $1 and $4 are NULLs */ + $1 and $4 are NULLs */ } break; @@ -7940,10 +7940,8 @@ add_lint(INSTRUCTION *list, LINTTYPE linttype) ; if (do_lint) { /* compile-time warning */ -#ifndef NO_LINT if (isnoeffect(ip->opcode)) lintwarn_ln(ip->source_line, ("statement may have no effect")); -#endif } if (ip->opcode == Op_push) { /* run-time warning */ -- cgit v1.2.3 From 8e4ebdf25bb000f7c84e6cba7c01975c01536f44 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 9 Oct 2013 21:32:25 +0300 Subject: Bug fix for $i++ = 3. --- awkgram.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'awkgram.c') diff --git a/awkgram.c b/awkgram.c index 947f4a30..1ca2791a 100644 --- a/awkgram.c +++ b/awkgram.c @@ -7576,8 +7576,13 @@ mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op) case Op_push_array: tp->opcode = Op_push_lhs; break; + case Op_field_assign: + yyerror(_("cannot assign a value to the result of a field post-increment expression")); + break; default: - cant_happen(); + yyerror(_("invalid target of assignment (opcode %s)"), + opcode2str(tp->opcode)); + break; } tp->do_reference = (op->opcode != Op_assign); /* check for uninitialized reference */ -- cgit v1.2.3 From c3f03fe1d5a7c1b2c7b8ff843afc506ce2a45811 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 16 Oct 2013 20:58:44 +0300 Subject: Fix -O option. --- awkgram.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'awkgram.c') diff --git a/awkgram.c b/awkgram.c index 1ca2791a..74913840 100644 --- a/awkgram.c +++ b/awkgram.c @@ -2848,7 +2848,7 @@ regular_loop: (void) list_prepend((yyval), instruction(Op_push_i)); (yyval)->nexti->memory = dupnode(Nnull_string); } else { - if (do_optimize > 1 + if (do_optimize && (yyvsp[(3) - (4)])->lasti->opcode == Op_func_call && strcmp((yyvsp[(3) - (4)])->lasti->func_name, in_function) == 0 ) { @@ -3518,7 +3518,7 @@ regular_print: */ } - if (do_optimize > 1 + if (do_optimize && (yyvsp[(1) - (2)])->nexti == (yyvsp[(1) - (2)])->lasti && (yyvsp[(1) - (2)])->nexti->opcode == Op_push_i && (yyvsp[(2) - (2)])->nexti == (yyvsp[(2) - (2)])->lasti && (yyvsp[(2) - (2)])->nexti->opcode == Op_push_i ) { @@ -3718,7 +3718,7 @@ regular_print: (yyval) = list_append(list_append(list_create((yyvsp[(1) - (2)])), instruction(Op_field_spec)), (yyvsp[(2) - (2)])); } else { - if (do_optimize > 1 && (yyvsp[(2) - (2)])->nexti == (yyvsp[(2) - (2)])->lasti + if (do_optimize && (yyvsp[(2) - (2)])->nexti == (yyvsp[(2) - (2)])->lasti && (yyvsp[(2) - (2)])->nexti->opcode == Op_push_i && ((yyvsp[(2) - (2)])->nexti->memory->flags & (MPFN|MPZN)) == 0 ) { @@ -6705,7 +6705,7 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def) thisfunc = fi->func_body; assert(thisfunc != NULL); - if (do_optimize > 1 && def->lasti->opcode == Op_pop) { + if (do_optimize && def->lasti->opcode == Op_pop) { /* tail call which does not return any value. */ INSTRUCTION *t; @@ -7233,7 +7233,7 @@ mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op) if (s2->lasti == ip2 && ip2->opcode == Op_push_i) { /* do any numeric constant folding */ ip1 = s1->nexti; - if (do_optimize > 1 + if (do_optimize && ip1 == s1->lasti && ip1->opcode == Op_push_i && (ip1->memory->flags & (MPFN|MPZN|STRCUR|STRING)) == 0 && (ip2->memory->flags & (MPFN|MPZN|STRCUR|STRING)) == 0 @@ -7652,10 +7652,8 @@ optimize_assignment(INSTRUCTION *exp) i2 = NULL; i1 = exp->lasti; - if ( ! do_optimize - || ( i1->opcode != Op_assign - && i1->opcode != Op_field_assign) - ) + if ( i1->opcode != Op_assign + && i1->opcode != Op_field_assign) return list_append(exp, instruction(Op_pop)); for (i2 = exp->nexti; i2 != i1; i2 = i2->nexti) { -- cgit v1.2.3