shithub: scc

Download patch

ref: 69ab3ec844f86006ab12f04df4fd75ca2ae55c5e
parent: 09c4bb6363f3ccc3c8835bcdf44bd6a42a564844
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Dec 14 08:41:37 EST 2016

[cc1] Create deftype()

This function does all the steps needed when a new type is defined,
instead of copying the same all the time.

--- a/cc1/types.c
+++ b/cc1/types.c
@@ -252,7 +252,7 @@
 }
 
 static Type *
-newtype(Type *base)
+newtype(Type *base, int defined)
 {
 	Type *tp;
 
@@ -265,10 +265,8 @@
 		tp->next = localtypes;
 		localtypes = tp;
 	}
-	if (tp->prop & TDEFINED) {
-		typesize(tp);
-		emit(OTYP, tp);
-	}
+	if (defined)
+		deftype(tp);
 	return tp;
 }
 
@@ -298,11 +296,9 @@
 		type.op = FTN;
 	case FTN:
 		type.letter = L_FUNCTION;
-		type.prop |= TDEFINED;
 		break;
 	case PTR:
 	        type.letter = L_POINTER;
-		type.prop |= TDEFINED;
 		break;
 	case ENUM:
 		type.letter = inttype->letter;
@@ -317,7 +313,7 @@
 		type.letter = L_UNION;
 		type.prop |= TAGGREG;
 	create_type:
-		return newtype(&type);
+		return newtype(&type, 0);
 	default:
 		abort();
 	}
@@ -335,7 +331,7 @@
 		}
 	}
 
-	bp = newtype(&type);
+	bp = newtype(&type, 1);
 	bp->h_next = *tbl;
 	*tbl = bp;