shithub: scc

Download patch

ref: 52efd1500ebcdd1b19b7ec791a5d1e427b655ab7
parent: 8c5632d62fb15b51382e21845995469d75cd96ab
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Mar 16 06:18:43 EDT 2015

Fix computation of stack frame size

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

--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -507,8 +507,12 @@
 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