aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/prc1/fn.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/prc1/fn.c b/src/prc1/fn.c
index 3a9809e..fa18f81 100644
--- a/src/prc1/fn.c
+++ b/src/prc1/fn.c
@@ -27,20 +27,22 @@ static const struct seq fnseq[] =
int fn_end(const struct lex *l, struct prv *p)
{
const struct fn *fn = fn_cur(p);
+ const struct tk *tk = fn->tk;
if (!fn->pr)
{
- const struct tk *tk = fn->tk;
const char *s = p->proto ? "prototype" : "function";
- errloc(p->stk - 1, "%s \"%s\" has no procedure", s, tk->s);
+ if (lex_eof(l, p->tk))
+ errloc(p->tk - 1, "%s \"%s\" has no procedure", s, tk->s);
+ else
+ errloc(p->tk, "unexpected \"%s\"", p->tk->s);
+
return -1;
}
else if (fn->nblocks)
{
- const struct tk *tk = lex_eof(l, p->stk) ? p->tk - 1 : p->stk;
-
- errloc(tk, "missing \"end\" in function \"%s\"", fn->tk->s);
+ errloc(tk, "missing \"end\" in function \"%s\"", tk->s);
return -1;
}