shithub: scc

Download patch

ref: 423f75f011f84fbc1ae9b439e34860f1d09d583f
parent: 53b8642aa9cedc398e937c31d7b5ca75c78b0ed9
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Aug 5 18:15:27 EDT 2015

Fix type in several declarations

--- a/cc1/code.c
+++ b/cc1/code.c
@@ -175,7 +175,7 @@
 
 	switch (BTYPE(np)) {
 	case INT:
-		printf("#%c%x", np->type->letter, sym->u.i);
+		printf("#%c%X", np->type->letter, sym->u.i);
 		break;
 	case ARY:
 		/*
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -14,7 +14,7 @@
 struct dcldata {
 	unsigned char op;
 	unsigned short nelem;
-	unsigned ndcl;
+	unsigned char ndcl;
 	void *data;
 };
 
@@ -140,7 +140,7 @@
 static Type *structdcl(void), *enumdcl(void);
 
 static Type *
-specifier(unsigned *sclass)
+specifier(int *sclass)
 {
 	Type *tp = NULL;
 	unsigned spec, qlf, sign, type, cls, size;
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -341,8 +341,7 @@
 static void
 stmt(Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
 {
-	void (*fun)(Symbol *lbreak, Symbol *lcont, Caselist *lswitch);
-	Node *np;
+	void (*fun)(Symbol *, Symbol *, Caselist *);
 
 	switch (yytoken) {
 	case '{':      fun = compound; break;
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -312,8 +312,12 @@
 	tbl = &typetab[t];
 	for (bp = *tbl; bp; bp = bp->next) {
 		if (eqtype(bp, &type)) {
-			/* FIXME: data can be a pointer to static data */
-			free(data);
+			/*
+			 * pars was allocated by the caller
+			 * but the type already exists, so
+			 * we have to deallocted it
+			 */
+			free(pars);
 			return bp;
 		}
 	}