aboutsummaryrefslogtreecommitdiff
path: root/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'decl.c')
-rw-r--r--decl.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/decl.c b/decl.c
index 0e9c776..6fb74fc 100644
--- 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;