scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 8f51e18e15eac2e434a0f51cf788d3b6b621566c
parent 6a8265d1262a3c63665f78a29d59d84387e8f68a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  8 Aug 2015 12:07:25 +0200

Fix check of storage validity in functions

Symbols have not yet the storage flags in declarator(),
so the correct point where do this validation is in
dodcl() after setting the flags.

Diffstat:
Mcc1/decl.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/cc1/decl.c b/cc1/decl.c @@ -202,8 +202,6 @@ declarator(Type *tp, unsigned ns) } sym->u.pars = pars; - if (tp->op == FTN && sym->flags & (ISREGISTER|ISAUTO)) - error("invalid storage class for function '%s'", sym->name); /* TODO: deal with external array declarations of [] */ if (!tp->defined && sym->name) @@ -529,6 +527,10 @@ dodcl(int rep, void (*fun)(Symbol *, int, Type *), uint8_t ns, Type *type) sym->token = TYPEIDEN; break; } + if (tp->op == FTN && (sym->flags & (ISREGISTER|ISAUTO))) { + error("invalid storage class for function '%s'", + sym->name); + } (*fun)(sym, sclass, type); } while (rep && !curfun && accept(','));