scc

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

commit 62ecef167f85476001bf9b22745b9113652077d9
parent bc8deaccc553b9709ee43dffbaa9580adf28e9fa
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 13 Dec 2016 17:34:11 +0100

[cc1] Remove lazy printout of types

Types were printed when was needed, when some variable related
to it was printed. This was a really bad idea because it was
generating a disorder in how the types were printed, and in
some cases global types were printed in the body of a function,
being deleted in flushtypes().

Diffstat:
Mcc1/arch/amd64-sysv/arch.c | 39+++++++++++++++++++--------------------
Mcc1/arch/i386-sysv/arch.c | 39+++++++++++++++++++--------------------
Mcc1/arch/qbe/arch.c | 39+++++++++++++++++++--------------------
Mcc1/arch/z80/arch.c | 39+++++++++++++++++++--------------------
Mcc1/cc1.h | 12++++++------
Mcc1/code.c | 21++++++++-------------
Mcc1/decl.c | 2++
Mcc1/types.c | 2+-
8 files changed, 93 insertions(+), 100 deletions(-)

diff --git a/cc1/arch/amd64-sysv/arch.c b/cc1/arch/amd64-sysv/arch.c @@ -33,19 +33,18 @@ static Type types[] = { { /* 0 = voidtype */ .op = VOID, .letter = L_VOID, - .prop = TPRINTED, }, { /* 1 = pvoidtype */ .op = PTR, .letter = L_POINTER, - .prop = TPRINTED | TDEFINED, + .prop = TDEFINED, .size = 8, .align = 8, }, { /* 2 = booltype */ .op = INT, .letter = L_BOOL, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 1, .align = 1, .n.rank = RANK_BOOL, @@ -53,7 +52,7 @@ static Type types[] = { { /* 3 = schartype */ .op = INT, .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 1, .align = 1, .n.rank = RANK_SCHAR, @@ -61,7 +60,7 @@ static Type types[] = { { /* 4 = uchartype */ .op = INT, .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 1, .align = 1, .n.rank = RANK_UCHAR, @@ -69,7 +68,7 @@ static Type types[] = { { /* 5 = chartype */ .op = INT, .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 1, .align = 1, .n.rank = RANK_CHAR, @@ -77,7 +76,7 @@ static Type types[] = { { /* 6 = ushortype */ .op = INT, .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 2, .align = 2, .n.rank = RANK_USHORT, @@ -85,7 +84,7 @@ static Type types[] = { { /* 7 = shortype */ .op = INT, .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 2, .align = 2, .n.rank = RANK_SHORT, @@ -93,7 +92,7 @@ static Type types[] = { { /* 8 = uinttype */ .op = INT, .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 4, .align = 4, .n.rank = RANK_UINT, @@ -101,7 +100,7 @@ static Type types[] = { { /* 9 = inttype */ .op = INT, .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 4, .align = 4, .n.rank = RANK_INT, @@ -109,7 +108,7 @@ static Type types[] = { { /* 10 = longtype */ .op = INT, .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 8, .align = 8, .n.rank = RANK_LONG, @@ -117,7 +116,7 @@ static Type types[] = { { /* 11 = ulongtype */ .op = INT, .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 8, .align = 8, .n.rank = RANK_ULONG, @@ -125,7 +124,7 @@ static Type types[] = { { /* 12 = ullongtype */ .op = INT, .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 8, .align = 8, .n.rank = RANK_ULLONG, @@ -133,7 +132,7 @@ static Type types[] = { { /* 13 = llongtype */ .op = INT, .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 8, .align = 8, .n.rank = RANK_LLONG, @@ -141,7 +140,7 @@ static Type types[] = { { /* 14 = floattype */ .op = FLOAT, .letter = L_FLOAT, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 4, .align = 4, .n.rank = RANK_FLOAT, @@ -149,7 +148,7 @@ static Type types[] = { { /* 15 = doubletype */ .op = FLOAT, .letter = L_DOUBLE, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 8, .align = 8, .n.rank = RANK_DOUBLE, @@ -157,7 +156,7 @@ static Type types[] = { { /* 16 = ldoubletype */ .op = FLOAT, .letter = L_LDOUBLE, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 16, .align = 16, .n.rank = RANK_LDOUBLE, @@ -165,7 +164,7 @@ static Type types[] = { { /* 17 = sizettype */ .op = INT, .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 8, .align = 8, .n.rank = RANK_UINT, @@ -173,12 +172,12 @@ static Type types[] = { { /* 18 = ellipsis */ .op = ELLIPSIS, .letter = L_ELLIPSIS, - .prop = TDEFINED | TPRINTED, + .prop = TDEFINED, }, { /* 19 = pdifftype */ .op = INT, .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 8, .align = 8, .n.rank = RANK_LONG, diff --git a/cc1/arch/i386-sysv/arch.c b/cc1/arch/i386-sysv/arch.c @@ -32,19 +32,18 @@ static Type types[] = { { /* 0 = voidtype */ .op = VOID, .letter = L_VOID, - .prop = TPRINTED, }, { /* 1 = pvoidtype */ .op = PTR, .letter = L_POINTER, - .prop = TDEFINED | TPRINTED, + .prop = TDEFINED, .size = 4, .align = 4, }, { /* 2 = booltype */ .op = INT, .letter = L_BOOL, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 1, .align = 1, .n.rank = RANK_BOOL, @@ -52,7 +51,7 @@ static Type types[] = { { /* 3 = schartype */ .op = INT, .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 1, .align = 1, .n.rank = RANK_SCHAR, @@ -60,7 +59,7 @@ static Type types[] = { { /* 4 = uchartype */ .op = INT, .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 1, .align = 1, .n.rank = RANK_UCHAR, @@ -68,7 +67,7 @@ static Type types[] = { { /* 5 = chartype */ .op = INT, .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 1, .align = 1, .n.rank = RANK_CHAR, @@ -76,7 +75,7 @@ static Type types[] = { { /* 6 = ushortype */ .op = INT, .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 2, .align = 2, .n.rank = RANK_USHORT, @@ -84,7 +83,7 @@ static Type types[] = { { /* 7 = shortype */ .op = INT, .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 2, .align = 2, .n.rank = RANK_SHORT, @@ -92,7 +91,7 @@ static Type types[] = { { /* 8 = uinttype */ .op = INT, .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 4, .align = 4, .n.rank = RANK_UINT, @@ -100,7 +99,7 @@ static Type types[] = { { /* 9 = inttype */ .op = INT, .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 4, .align = 4, .n.rank = RANK_INT, @@ -108,7 +107,7 @@ static Type types[] = { { /* 10 = longtype */ .op = INT, .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 4, .align = 4, .n.rank = RANK_LONG, @@ -116,7 +115,7 @@ static Type types[] = { { /* 11 = ulongtype */ .op = INT, .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 4, .align = 4, .n.rank = RANK_ULONG, @@ -124,7 +123,7 @@ static Type types[] = { { /* 12 = ullongtype */ .op = INT, .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 8, .align = 4, .n.rank = RANK_ULLONG, @@ -132,7 +131,7 @@ static Type types[] = { { /* 13 = llongtype */ .op = INT, .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 8, .align = 4, .n.rank = RANK_LLONG, @@ -140,7 +139,7 @@ static Type types[] = { { /* 14 = floattype */ .op = FLOAT, .letter = L_FLOAT, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 4, .align = 4, .n.rank = RANK_FLOAT, @@ -148,7 +147,7 @@ static Type types[] = { { /* 15 = doubletype */ .op = FLOAT, .letter = L_DOUBLE, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 8, .align = 4, .n.rank = RANK_DOUBLE, @@ -156,7 +155,7 @@ static Type types[] = { { /* 16 = ldoubletype */ .op = FLOAT, .letter = L_LDOUBLE, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 12, .align = 4, .n.rank = RANK_LDOUBLE, @@ -164,7 +163,7 @@ static Type types[] = { { /* 17 = sizettype */ .op = INT, .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 4, .align = 4, .n.rank = RANK_UINT, @@ -172,12 +171,12 @@ static Type types[] = { { /* 18 = ellipsis */ .op = ELLIPSIS, .letter = L_ELLIPSIS, - .prop = TDEFINED | TPRINTED, + .prop = TDEFINED, }, { /* 19 = pdifftype */ .op = INT, .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 4, .align = 4, .n.rank = RANK_INT, diff --git a/cc1/arch/qbe/arch.c b/cc1/arch/qbe/arch.c @@ -33,19 +33,18 @@ static Type types[] = { { /* 0 = voidtype */ .op = VOID, .letter = L_VOID, - .prop = TPRINTED, }, { /* 1 = pvoidtype */ .op = PTR, .letter = L_POINTER, - .prop = TDEFINED | TPRINTED, + .prop = TDEFINED, .size = 8, .align = 8, }, { /* 2 = booltype */ .op = INT, .letter = L_BOOL, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 1, .align = 1, .n.rank = RANK_BOOL, @@ -53,7 +52,7 @@ static Type types[] = { { /* 3 = schartype */ .op = INT, .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | SIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | SIGNED, .size = 1, .align = 1, .n.rank = RANK_SCHAR, @@ -61,7 +60,7 @@ static Type types[] = { { /* 4 = uchartype */ .op = INT, .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 1, .align = 1, .n.rank = RANK_UCHAR, @@ -69,7 +68,7 @@ static Type types[] = { { /* 5 = chartype */ .op = INT, .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 1, .align = 1, .n.rank = RANK_CHAR, @@ -77,7 +76,7 @@ static Type types[] = { { /* 6 = ushortype */ .op = INT, .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 2, .align = 2, .n.rank = RANK_USHORT, @@ -85,7 +84,7 @@ static Type types[] = { { /* 7 = shortype */ .op = INT, .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 2, .align = 2, .n.rank = RANK_SHORT, @@ -93,7 +92,7 @@ static Type types[] = { { /* 8 = uinttype */ .op = INT, .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 4, .align = 4, .n.rank = RANK_UINT, @@ -101,7 +100,7 @@ static Type types[] = { { /* 9 = inttype */ .op = INT, .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 4, .align = 4, .n.rank = RANK_INT, @@ -109,7 +108,7 @@ static Type types[] = { { /* 10 = longtype */ .op = INT, .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 8, .align = 8, .n.rank = RANK_LONG, @@ -117,7 +116,7 @@ static Type types[] = { { /* 11 = ulongtype */ .op = INT, .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 8, .align = 8, .n.rank = RANK_ULONG, @@ -125,7 +124,7 @@ static Type types[] = { { /* 12 = ullongtype */ .op = INT, .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 8, .align = 8, .n.rank = RANK_ULLONG, @@ -133,7 +132,7 @@ static Type types[] = { { /* 13 = llongtype */ .op = INT, .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 8, .align = 8, .n.rank = RANK_LLONG, @@ -141,7 +140,7 @@ static Type types[] = { { /* 14 = floattype */ .op = FLOAT, .letter = L_FLOAT, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 4, .align = 4, .n.rank = RANK_FLOAT, @@ -149,7 +148,7 @@ static Type types[] = { { /* 15 = doubletype */ .op = FLOAT, .letter = L_DOUBLE, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 8, .align = 8, .n.rank = RANK_DOUBLE, @@ -157,7 +156,7 @@ static Type types[] = { { /* 16 = ldoubletype */ .op = FLOAT, .letter = L_LDOUBLE, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 16, .align = 16, .n.rank = RANK_LDOUBLE, @@ -165,7 +164,7 @@ static Type types[] = { { /* 17 = sizettype */ .op = INT, .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 8, .align = 8, .n.rank = RANK_UINT, @@ -173,12 +172,12 @@ static Type types[] = { { /* 18 = ellipsis */ .op = ELLIPSIS, .letter = L_ELLIPSIS, - .prop = TDEFINED | TPRINTED, + .prop = TDEFINED, }, { /* 19 = pdifftype */ .op = INT, .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 8, .align = 8, .n.rank = RANK_LONG, diff --git a/cc1/arch/z80/arch.c b/cc1/arch/z80/arch.c @@ -33,19 +33,18 @@ static Type types[] = { { /* 0 = voidtype */ .op = VOID, .letter = L_VOID, - .prop = TPRINTED, }, { /* 1 = pvoidtype */ .op = PTR, .letter = L_POINTER, - .prop = TDEFINED | TPRINTED, + .prop = TDEFINED, .size = 2, .align = 2, }, { /* 2 = booltype */ .op = INT, .letter = L_BOOL, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 1, .align = 1, .n.rank = RANK_BOOL, @@ -53,7 +52,7 @@ static Type types[] = { { /* 3 = schartype */ .op = INT, .letter = L_INT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 1, .align = 1, .n.rank = RANK_SCHAR, @@ -61,7 +60,7 @@ static Type types[] = { { /* 4 = uchartype */ .op = INT, .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 1, .align = 1, .n.rank = RANK_UCHAR, @@ -69,7 +68,7 @@ static Type types[] = { { /* 5 = chartype */ .op = INT, .letter = L_UINT8, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 1, .align = 1, .n.rank = RANK_CHAR, @@ -77,7 +76,7 @@ static Type types[] = { { /* 6 = ushortype */ .op = INT, .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 2, .align = 1, .n.rank = RANK_USHORT, @@ -85,7 +84,7 @@ static Type types[] = { { /* 7 = shortype */ .op = INT, .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 2, .align = 1, .n.rank = RANK_SHORT, @@ -93,7 +92,7 @@ static Type types[] = { { /* 8 = uinttype */ .op = INT, .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 2, .align = 1, .n.rank = RANK_UINT, @@ -101,7 +100,7 @@ static Type types[] = { { /* 9 = inttype */ .op = INT, .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 2, .align = 1, .n.rank = RANK_INT, @@ -109,7 +108,7 @@ static Type types[] = { { /* 10 = longtype */ .op = INT, .letter = L_INT32, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 4, .align = 1, .n.rank = RANK_LONG, @@ -117,7 +116,7 @@ static Type types[] = { { /* 11 = ulongtype */ .op = INT, .letter = L_UINT32, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 4, .align = 1, .n.rank = RANK_ULONG, @@ -125,7 +124,7 @@ static Type types[] = { { /* 12 = ullongtype */ .op = INT, .letter = L_UINT64, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 8, .align = 1, .n.rank = RANK_ULLONG, @@ -133,7 +132,7 @@ static Type types[] = { { /* 13 = llongtype */ .op = INT, .letter = L_INT64, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 8, .align = 1, .n.rank = RANK_LLONG, @@ -141,7 +140,7 @@ static Type types[] = { { /* 14 = floattype */ .op = FLOAT, .letter = L_FLOAT, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 4, .align = 1, .n.rank = RANK_FLOAT, @@ -149,7 +148,7 @@ static Type types[] = { { /* 15 = doubletype */ .op = FLOAT, .letter = L_DOUBLE, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 8, .align = 1, .n.rank = RANK_DOUBLE, @@ -157,7 +156,7 @@ static Type types[] = { { /* 16 = ldoubletype */ .op = FLOAT, .letter = L_LDOUBLE, - .prop = TDEFINED | TARITH | TPRINTED, + .prop = TDEFINED | TARITH, .size = 16, .align = 1, .n.rank = RANK_LDOUBLE, @@ -165,7 +164,7 @@ static Type types[] = { { /* 17 = sizettype */ .op = INT, .letter = L_UINT16, - .prop = TDEFINED | TINTEGER | TARITH | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH, .size = 2, .align = 1, .n.rank = RANK_UINT, @@ -173,12 +172,12 @@ static Type types[] = { { /* 18 = ellipsis */ .op = ELLIPSIS, .letter = L_ELLIPSIS, - .prop = TDEFINED | TPRINTED, + .prop = TDEFINED, }, { /* 7 = pdifftype */ .op = INT, .letter = L_INT16, - .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED, + .prop = TDEFINED | TINTEGER | TARITH | TSIGNED, .size = 2, .align = 1, .n.rank = RANK_SHORT, diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -13,11 +13,10 @@ enum typeprops { TDEFINED = 1 << 0, /* type defined */ TSIGNED = 1 << 1, /* signedness of the type */ - TPRINTED = 1 << 2, /* the type was already printed */ - TINTEGER = 1 << 3, /* the type is INT of enum */ - TARITH = 1 << 4, /* the type is INT, ENUM or FLOAT */ - TAGGREG = 1 << 5, /* the type is struct or union */ - TK_R = 1 << 6, /* this is a K&R-function */ + TINTEGER = 1 << 2, /* the type is INT of enum */ + TARITH = 1 << 3, /* the type is INT, ENUM or FLOAT */ + TAGGREG = 1 << 4, /* the type is struct or union */ + TK_R = 1 << 5, /* this is a K&R-function */ }; /* data type letters */ @@ -246,7 +245,8 @@ enum op { ODECL, OBSWITCH, OESWITCH, - OINIT + OINIT, + OTYP, }; /* diff --git a/cc1/code.c b/cc1/code.c @@ -16,7 +16,8 @@ static void emitbin(unsigned, void *), emittext(unsigned, void *), emitfun(unsigned, void *), emitdcl(unsigned, void *), - emitinit(unsigned, void *); + emitinit(unsigned, void *), + emittype(unsigned, void *); char *optxt[] = { [OADD] = "+", @@ -132,7 +133,8 @@ void (*opcode[])(unsigned, void *) = { [OESWITCH] = emitsymid, [OPAR] = emitbin, [OCALL] = emitbin, - [OINIT] = emitinit + [OINIT] = emitinit, + [OTYP] = emittype, }; void @@ -236,33 +238,26 @@ emitletter(Type *tp) } static void -emittype(Type *tp) +emittype(unsigned op, void *arg) { TINT n; Symbol **sp; char *tag; + Type *tp = arg; - if ((tp->prop & TPRINTED) || !(tp->prop & TDEFINED)) + if (!(tp->prop & TDEFINED)) return; - tp->prop |= TPRINTED; switch (tp->op) { case ARY: - emittype(tp->type); emitletter(tp); putchar('\t'); emitletter(tp->type); printf("\t#%c%llX\n", sizettype->letter, (long long) tp->n.elem); return; - case PTR: - emittype(tp->type); - return; case UNION: case STRUCT: - n = tp->n.elem; - for (sp = tp->p.fields; n-- > 0; ++sp) - emittype((*sp)->type); emitletter(tp); tag = tp->tag->name; printf("\t\"%s\t#%c%lX\t#%c%X\n", @@ -275,6 +270,7 @@ emittype(Type *tp) for (sp = tp->p.fields; n-- > 0; ++sp) emit(ODECL, *sp); break; + case PTR: case FTN: return; default: @@ -377,7 +373,6 @@ emitdcl(unsigned op, void *arg) if (sym->flags & SEMITTED) return; - emittype(sym->type); emitvar(sym); putchar('\t'); if (sym->type->op == FTN) { diff --git a/cc1/decl.c b/cc1/decl.c @@ -533,6 +533,7 @@ structdcl(void) --nested; typesize(tp); + emit(OTYP, tp); namespace = ns; expect('}'); return tp; @@ -555,6 +556,7 @@ enumdcl(void) if (tp->prop & TDEFINED) errorp("redefinition of enumeration '%s'", tagsym->name); tp->prop |= TDEFINED; + emit(OTYP, tp); typesize(tp); namespace = NS_IDEN; diff --git a/cc1/types.c b/cc1/types.c @@ -308,7 +308,7 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[]) break; case ENUM: type.letter = inttype->letter; - type.prop |= TPRINTED | TINTEGER | TARITH; + type.prop |= TINTEGER | TARITH; type.n.rank = inttype->n.rank; goto create_type; case STRUCT: