scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit c73e0b8d57ea9f47ac5de40e54eb32aacdca28f6
parent 24f5b053a44666a9fa66c8ed71cedb797b621b3d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 14 Dec 2016 13:41:37 +0100

[cc1] Create deftype()

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

Diffstat:
Mcc1/types.c | 14+++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/cc1/types.c b/cc1/types.c @@ -252,7 +252,7 @@ deftype(Type *tp) } static Type * -newtype(Type *base) +newtype(Type *base, int defined) { Type *tp; @@ -265,10 +265,8 @@ newtype(Type *base) tp->next = localtypes; localtypes = tp; } - if (tp->prop & TDEFINED) { - typesize(tp); - emit(OTYP, tp); - } + if (defined) + deftype(tp); return tp; } @@ -298,11 +296,9 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[]) 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 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[]) type.letter = L_UNION; type.prop |= TAGGREG; create_type: - return newtype(&type); + return newtype(&type, 0); default: abort(); } @@ -335,7 +331,7 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[]) } } - bp = newtype(&type); + bp = newtype(&type, 1); bp->h_next = *tbl; *tbl = bp;