diff options
author | Michael Forney <mforney@mforney.org> | 2019-02-17 12:10:10 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-02-17 12:10:10 -0800 |
commit | 8f75d2840daf36870bee142709530586d138ce63 (patch) | |
tree | acbc29590e8982a62b2ad5206a79f0694d5197f8 | |
parent | 6e457e2a7da38bf5ea9779f30deb21dbb78f2ebd (diff) | |
download | cproc-8f75d2840daf36870bee142709530586d138ce63.tar.xz |
Only parse function definitions for function declarations
-rw-r--r-- | decl.c | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -849,21 +849,22 @@ decl(struct scope *s, struct function *f) d->value = mkglobal(name, false); scopeputdecl(s, name, d); } + if (tok.kind == TLBRACE) { + if (!allowfunc) + error(&tok.loc, "function declaration not allowed"); + if (d->defined) + error(&tok.loc, "function '%s' redefined", name); + s = mkscope(&filescope); + f = mkfunc(name, t, s); + stmt(f, s); + emitfunc(f, d->linkage == LINKEXTERN); + s = delscope(s); + d->defined = true; + return true; + } break; } switch (tok.kind) { - case TLBRACE: - if (!allowfunc) - error(&tok.loc, "function declaration not allowed"); - if (d->defined) - error(&tok.loc, "function '%s' redefined", name); - s = mkscope(&filescope); - f = mkfunc(name, t, s); - stmt(f, s); - emitfunc(f, d->linkage == LINKEXTERN); - s = delscope(s); - d->defined = true; - return true; case TCOMMA: next(); allowfunc = 0; |