shithub: scc

Download patch

ref: 3ab95a29ff772382f84e85eba3b037c1bd96d97c
parent: 20b4457a8bb3aca439e4d1cfa538355b6da82c56
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Oct 7 05:40:30 EDT 2016

[cc1] Remove duptype()

This function was created only to avoid exporting newid(),
but the solution was worse than the original problem.

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -368,6 +368,7 @@
 extern Symbol *newlabel(void);
 extern void keywords(struct keyword *key, int ns);
 extern Symbol *newstring(char *s, size_t len);
+extern unsigned newid(void);
 
 /* stmt.c */
 extern void compound(Symbol *lbreak, Symbol *lcont, Switch *sw);
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -122,7 +122,7 @@
 	head = sym;
 }
 
-static unsigned short
+unsigned
 newid(void)
 {
 	unsigned short id;
@@ -133,16 +133,6 @@
 		    (curctx) ? "internal" : "external");
 	}
 	return id;
-}
-
-Type *
-duptype(Type *base)
-{
-	Type *tp = xmalloc(sizeof(*tp));
-
-	*tp = *base;
-	tp->id = newid();
-	return tp;
 }
 
 static Symbol *
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -308,8 +308,9 @@
 		}
 	}
 
-	typesize(&type);
-	bp = duptype(&type);
+	bp = xmalloc(sizeof(*bp));
+	*bp = type;
+	bp->id = newid();
 	bp->next = *tbl;
 	return *tbl = bp;
 }