scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit da8e1d6c8cd2711d7a8566bf658399fbe3531b39
parent 63284fa474d0474e85fd63a0b2fb00878f7efeee
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 20 Jul 2015 22:07:23 +0200

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.

Diffstat:
Mcc1/cc1.h | 2+-
Mcc1/code.c | 2+-
Mcc1/types.c | 12+++++++++---
3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -343,7 +343,7 @@ extern int lexmode; extern Type *voidtype, *pvoidtype, *booltype, *uchartype, *chartype, - *uinttype, *inttype, *sizetp, + *uinttype, *inttype, *sizettype, *ushortype, *shortype, *longtype, *ulongtype, *ullongtype, *llongtype, diff --git a/cc1/code.c b/cc1/code.c @@ -345,7 +345,7 @@ sizeofnode(Type *tp) Symbol *sym; sym = newsym(NS_IDEN); - sym->type = sizetp; + sym->type = sizettype; sym->u.i = tp->size; return constnode(sym); } diff --git a/cc1/types.c b/cc1/types.c @@ -147,6 +147,14 @@ static Type types[] = { .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 @@ Type *voidtype = &types[0], *pvoidtype = &types[1], *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]};