cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 8f75d2840daf36870bee142709530586d138ce63
parent 6e457e2a7da38bf5ea9779f30deb21dbb78f2ebd
Author: Michael Forney <mforney@mforney.org>
Date:   Sun, 17 Feb 2019 12:10:10 -0800

Only parse function definitions for function declarations

Diffstat:
Mdecl.c | 25+++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/decl.c b/decl.c @@ -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;