aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-05-20 23:15:17 +0300
committerArnold D. Robbins <arnold@skeeve.com>2017-05-20 23:15:17 +0300
commita3d548382b056d681d9cca957a683931212880b2 (patch)
tree5ae269fd3ee7feff6d9330419fa6d77c8ba21010 /awkgram.c
parent063ac75f58041edcca56cc0112ecf5764ebaea52 (diff)
parent0f9d4355a03d000938d87d71ba62f0ac2717334a (diff)
downloadegawk-a3d548382b056d681d9cca957a683931212880b2.tar.gz
egawk-a3d548382b056d681d9cca957a683931212880b2.tar.bz2
egawk-a3d548382b056d681d9cca957a683931212880b2.zip
Merge branch 'master' into feature/fix-comments
Diffstat (limited to 'awkgram.c')
-rw-r--r--awkgram.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/awkgram.c b/awkgram.c
index 76288670..c022782b 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -8349,12 +8349,22 @@ add_lint(INSTRUCTION *list, LINTTYPE linttype)
case LINT_no_effect:
if (list->lasti->opcode == Op_pop && list->nexti != list->lasti) {
- for (ip = list->nexti; ip->nexti != list->lasti; ip = ip->nexti)
- ;
+ int line = 0;
+
+ // Get down to the last instruction (FIXME: why?)
+ for (ip = list->nexti; ip->nexti != list->lasti; ip = ip->nexti) {
+ // along the way track line numbers, we will use the line
+ // closest to the opcode if that opcode doesn't have one
+ if (ip->source_line != 0)
+ line = ip->source_line;
+ }
if (do_lint) { /* compile-time warning */
- if (isnoeffect(ip->opcode))
- lintwarn_ln(ip->source_line, ("statement may have no effect"));
+ if (isnoeffect(ip->opcode)) {
+ if (ip->source_line != 0)
+ line = ip->source_line;
+ lintwarn_ln(line, ("statement may have no effect"));
+ }
}
if (ip->opcode == Op_push) { /* run-time warning */