scc

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

commit 52efd1500ebcdd1b19b7ec791a5d1e427b655ab7
parent 8c5632d62fb15b51382e21845995469d75cd96ab
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 16 Mar 2015 10:18:43 +0000

Fix computation of stack frame size

Only register and automatic variables must be accounted
in the size of the stack frame.

Diffstat:
cc2/parser.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -507,8 +507,12 @@ static void localdcl(char *token) { Symbol *sym = declaration(LOCAL, token[0], token); - curfun->u.f.locals += sym->u.v.type.size; - sym->u.v.off = 1-curfun->u.f.locals; + char sclass = *token; + + if (sclass == 'A' || sclass == 'R') { + curfun->u.f.locals += sym->u.v.type.size; + sym->u.v.off = 1-curfun->u.f.locals; + } } void