scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 40f728bbc37cdce07a2dd000dfa81c0dfe0b307a
parent 401f843e3fd7dd3399a30d79b1a35f1340909dbe
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 10 Jan 2016 16:53:14 +0100

Remove indentation level in decl()

Diffstat:
cc1/decl.c | 63+++++++++++++++++++++++++++++----------------------------------
1 file changed, 29 insertions(+), 34 deletions(-)

diff --git a/cc1/decl.c b/cc1/decl.c @@ -769,42 +769,37 @@ decl(void) * but due to parameter context, we have to check * against GLOBALCTX+1 */ - if (sym->type->op == FTN) { - if (curctx != GLOBALCTX+1) - goto prototype; + if (sym->type->op != FTN) { + expect(';'); + return; + } - switch (yytoken) { - case '{': - case TYPEIDEN: - case TYPE: - case TQUALIFIER: - case SCLASS: - if (sym->flags & ISTYPEDEF) - errorp("function definition declared 'typedef'"); - if (sym->flags & ISDEFINED) - errorp("redefinition of '%s'", sym->name); - if (sym->flags & ISEXTERN) { - sym->flags &= ~ISEXTERN; - sym->flags |= ISGLOBAL; - } - sym->flags |= ISDEFINED; - sym->flags &= ~ISEMITTED; - curfun = sym; - emit(OFUN, sym); - free(sym->u.pars); - compound(NULL, NULL, NULL); - emit(OEFUN, NULL); - curfun = NULL; - return; - default: - prototype: - emit(ODECL, sym); - free(sym->u.pars); - sym->u.pars = NULL; - popctx(); - } + if (curctx != GLOBALCTX+1 || yytoken == ';') { + /* it is a prototype */ + emit(ODECL, sym); + free(sym->u.pars); + sym->u.pars = NULL; + popctx(); + expect(';'); + return; } - expect(';'); + + if (sym->flags & ISTYPEDEF) + errorp("function definition declared 'typedef'"); + if (sym->flags & ISDEFINED) + errorp("redefinition of '%s'", sym->name); + if (sym->flags & ISEXTERN) { + sym->flags &= ~ISEXTERN; + sym->flags |= ISGLOBAL; + } + sym->flags |= ISDEFINED; + sym->flags &= ~ISEMITTED; + curfun = sym; + emit(OFUN, sym); + free(sym->u.pars); + compound(NULL, NULL, NULL); + emit(OEFUN, NULL); + curfun = NULL; } static void