summaryrefslogtreecommitdiff
path: root/src/cmd/gc/subr.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2008-11-18 09:32:05 -0800
committerRuss Cox <rsc@golang.org>2008-11-18 09:32:05 -0800
commit63198ed6b2a2fa2ff7ae1f23d7d24a7699e45bba (patch)
tree8e61d34db82738faa800a7704d171ded75f7bb32 /src/cmd/gc/subr.c
parentf7bca3896e089d631185133661d77d77083d20c8 (diff)
downloadgolang-63198ed6b2a2fa2ff7ae1f23d7d24a7699e45bba.tar.gz
use correct lineno in nod even if yacc has looked ahead.
makes lineno correct for statements without semicolons. R=ken OCL=19454 CL=19454
Diffstat (limited to 'src/cmd/gc/subr.c')
-rw-r--r--src/cmd/gc/subr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c
index e1bdde5f5..851f17404 100644
--- a/src/cmd/gc/subr.c
+++ b/src/cmd/gc/subr.c
@@ -269,6 +269,7 @@ dcl(void)
return d;
}
+extern int yychar;
Node*
nod(int op, Node *nleft, Node *nright)
{
@@ -278,7 +279,10 @@ nod(int op, Node *nleft, Node *nright)
n->op = op;
n->left = nleft;
n->right = nright;
- n->lineno = lineno;
+ if(yychar <= 0) // no lookahead
+ n->lineno = lineno;
+ else
+ n->lineno = prevlineno;
return n;
}