shithub: scc

Download patch

ref: da8e1d6c8cd2711d7a8566bf658399fbe3531b39
parent: 63284fa474d0474e85fd63a0b2fb00878f7efeee
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Jul 20 18:07:23 EDT 2015

Deal size_t like any other type

The important point in the types in the current
implementation is the value of the fields, so two
types can be represented by different pointers,
with different values that if they have the same
values then they will be the same type. For this
reason is better keep size_t like a common type.

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -343,7 +343,7 @@
 
 extern Type *voidtype, *pvoidtype, *booltype,
             *uchartype,   *chartype,
-            *uinttype,    *inttype,     *sizetp,
+            *uinttype,    *inttype,     *sizettype,
             *ushortype,   *shortype,
             *longtype,    *ulongtype,
             *ullongtype,  *llongtype,
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -345,7 +345,7 @@
 	Symbol *sym;
 
 	sym = newsym(NS_IDEN);
-	sym->type = sizetp;
+	sym->type = sizettype;
 	sym->u.i = tp->size;
 	return constnode(sym);
 }
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -147,6 +147,14 @@
 		.size = 16,
 		.align = 1,
 		.n.rank = RANK_LDOUBLE
+	},
+	{       /* 17 = sizettype */
+		.op = INT,
+		.letter = L_UINT,
+		.defined = 1,
+		.size = 2,
+		.align = 1,
+		.n.rank = RANK_UINT
 	}
 };
 
@@ -158,9 +166,7 @@
 	*longtype = &types[10], *ulongtype = &types[11],
 	*ullongtype = &types[12], *llongtype = &types[13],
 	*floattype = &types[14], *doubletype = &types[15],
-	*ldoubletype = &types[16];
-
-Type *sizetp = &types[8]; /* TODO: This depend of the target */
+	*ldoubletype = &types[16], *sizettype = &types[17];
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
               dummy1 = {.u.i = 1, .type = &types[9]};