diff options
Diffstat (limited to 'awkgram.c')
-rw-r--r-- | awkgram.c | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -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; @@ -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 @@ -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 */ @@ -7647,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) { @@ -7940,10 +7943,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 */ |