diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | awkgram.c | 7 | ||||
-rw-r--r-- | awkgram.y | 7 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 3 | ||||
-rw-r--r-- | test/Makefile.in | 8 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/badassign1.awk | 1 | ||||
-rw-r--r-- | test/badassign1.ok | 3 |
9 files changed, 42 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2013-10-09 Arnold D. Robbins <arnold@skeeve.com> + + * awkgram.y (mk_assignment): Rework switch to handle Op_assign, + and to provide a better error message upon unknown opcode. + 2013-09-28 Arnold D. Robbins <arnold@skeeve.com> * dfa.c: Sync with GNU grep. @@ -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 */ @@ -5028,8 +5028,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 */ diff --git a/test/ChangeLog b/test/ChangeLog index ad0366f2..c835eb01 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2013-10-09 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (badassign1): New test. + * badassign1.awk, badassign1.ok: New files. + 2013-09-13 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am: Fix quoting for generation of Maketests file so diff --git a/test/Makefile.am b/test/Makefile.am index 8288cf7d..b3a9a58f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -113,6 +113,8 @@ EXTRA_DIST = \ backw.in \ backw.ok \ badargs.ok \ + badassign1.awk \ + badassign1.ok \ beginfile1.awk \ beginfile1.ok \ beginfile2.in \ @@ -931,6 +933,7 @@ BASIC_TESTS = \ arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \ aryprm8 arysubnm asgext awkpath \ back89 backgsub \ + badassign1 \ childin clobber closebad clsflnam compare compare2 concat1 concat2 \ concat3 concat4 convfmt \ datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \ diff --git a/test/Makefile.in b/test/Makefile.in index 31a22602..637bad0d 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -331,6 +331,8 @@ EXTRA_DIST = \ backw.in \ backw.ok \ badargs.ok \ + badassign1.awk \ + badassign1.ok \ beginfile1.awk \ beginfile1.ok \ beginfile2.in \ @@ -1148,6 +1150,7 @@ BASIC_TESTS = \ arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \ aryprm8 arysubnm asgext awkpath \ back89 backgsub \ + badassign1 \ childin clobber closebad clsflnam compare compare2 concat1 concat2 \ concat3 concat4 convfmt \ datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \ @@ -2373,6 +2376,11 @@ backgsub: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +badassign1: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + childin: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index a1791a92..df272ce8 100644 --- a/test/Maketests +++ b/test/Maketests @@ -120,6 +120,11 @@ backgsub: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +badassign1: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + childin: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/badassign1.awk b/test/badassign1.awk new file mode 100644 index 00000000..5614f4a4 --- /dev/null +++ b/test/badassign1.awk @@ -0,0 +1 @@ +BEGIN { $i++ = 3 ; print i } diff --git a/test/badassign1.ok b/test/badassign1.ok new file mode 100644 index 00000000..c5ade3b3 --- /dev/null +++ b/test/badassign1.ok @@ -0,0 +1,3 @@ +gawk: badassign1.awk:1: BEGIN { $i++ = 3 ; print i } +gawk: badassign1.awk:1: ^ cannot assign a value to the result of a field post-increment expression +EXIT CODE: 1 |