scc

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

commit 0eef6fc79e97b9097d8bc5a1f0e93aa4248649b9
parent 9c45c2b5f383585dedcede18b0d0cac97b27ab1c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 10 Sep 2014 20:31:45 +0200

Pass a storage class parameter to declaration

This parameter simplifies all the logic of the code later.

Diffstat:
Mcc2/parser.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -381,7 +381,7 @@ endfunction(char *token) } static Symbol * -declaration(uint8_t t, char *token) +declaration(uint8_t t, char class, char *token) { static Symbol *(*tbl[3])(char *)= { [LOCAL] = local, @@ -397,7 +397,7 @@ declaration(uint8_t t, char *token) free(sym->name); memset(sym, 0, sizeof(*sym)); sym->type = VAR; - sym->u.v.sclass = token[0]; + sym->u.v.sclass = class; if ((s = strtok(NULL, "\t")) == NULL) error(ESYNTAX); @@ -411,7 +411,7 @@ declaration(uint8_t t, char *token) static void globdcl(char *token) { - Symbol *sym = declaration(GLOBAL, token); + Symbol *sym = declaration(GLOBAL, MEM, token); switch (token[0]) { case 'X': @@ -439,7 +439,7 @@ globdcl(char *token) static void paramdcl(char *token) { - Symbol *sym = declaration(PARAMETER, token); + Symbol *sym = declaration(PARAMETER, AUTO, token); sym->next = curfun->u.f.pars; curfun->u.f.pars = sym; } @@ -447,7 +447,7 @@ paramdcl(char *token) static void localdcl(char *token) { - Symbol *sym = declaration(LOCAL, token); + Symbol *sym = declaration(LOCAL, token[0], token); sym->next = curfun->u.f.vars; curfun->u.f.vars = sym; }