commit cdc25f13748ccf9b0de99c6c7da518f76681ea57
parent 56f5f69eaf1249765514d8818d664b5c1c1a6388
Author: FRIGN <dev@frign.de>
Date: Wed, 18 May 2016 12:15:52 +0200
Replace struct type bitfield with enum-bitflags
This simplifies the code in many places. Also update tests to
reflect prior changes.
"La noche es la mejor representación de la infinitud del universo. Nos
hace creer que nada tiene principio y nada, fin."
- Carlos Fuentes
Diffstat:
13 files changed, 150 insertions(+), 377 deletions(-)
diff --git a/cc1/arch/amd64-sysv/arch.c b/cc1/arch/amd64-sysv/arch.c
@@ -17,212 +17,155 @@ static Type types[] = {
{ /* 0 = voidtype */
.op = VOID,
.letter = L_VOID,
- .printed = 1
+ .prop = TPRINTED,
},
{ /* 1 = pvoidtype */
.op = PTR,
.letter = L_POINTER,
+ .prop = TPRINTED | TDEFINED,
.size = 2,
.align = 2,
- .printed = 1,
- .defined = 1,
},
{ /* 2 = booltype */
.op = INT,
.letter = L_BOOL,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_BOOL,
- .printed = 1
},
{ /* 3 = schartype */
.op = INT,
.letter = L_INT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_SCHAR,
- .printed = 1
},
{ /* 4 = uchartype */
.op = INT,
.letter = L_UINT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_UCHAR,
- .printed = 1
},
{ /* 5 = chartype */
.op = INT,
.letter = L_INT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_CHAR,
- .printed = 1
},
{ /* 6 = ushortype */
.op = INT,
.letter = L_UINT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 2,
.n.rank = RANK_USHORT,
- .printed = 1
},
{ /* 7 = shortype */
.op = INT,
.letter = L_INT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 2,
- .sign = 1,
.n.rank = RANK_SHORT,
- .printed = 1
},
{ /* 8 = uinttype */
.op = INT,
.letter = L_UINT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
.n.rank = RANK_UINT,
- .printed = 1
},
{ /* 9 = inttype */
.op = INT,
.letter = L_INT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
- .sign = 1,
.n.rank = RANK_INT,
- .printed = 1
},
{ /* 10 = longtype */
.op = INT,
.letter = L_INT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
- .sign = 1,
.n.rank = RANK_LONG,
- .printed = 1
},
{ /* 11 = ulongtype */
.op = INT,
.letter = L_UINT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
.n.rank = RANK_ULONG,
- .printed = 1
},
{ /* 12 = ullongtype */
.op = INT,
.letter = L_UINT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
.n.rank = RANK_ULLONG,
- .printed = 1
},
{ /* 13 = llongtype */
.op = INT,
.letter = L_INT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
- .sign = 1,
.n.rank = RANK_LLONG,
- .printed = 1
},
{ /* 14 = floattype */
.op = FLOAT,
.letter = L_FLOAT,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 4,
- .arith = 1,
.align = 4,
.n.rank = RANK_FLOAT,
- .printed = 1
},
{ /* 15 = doubletype */
.op = FLOAT,
.letter = L_DOUBLE,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 8,
- .arith = 1,
.align = 8,
.n.rank = RANK_DOUBLE,
- .printed = 1
},
{ /* 16 = ldoubletype */
.op = FLOAT,
.letter = L_LDOUBLE,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 16,
- .arith = 1,
.align = 16,
.n.rank = RANK_LDOUBLE,
- .printed = 1
},
{ /* 17 = sizettype */
.op = INT,
.letter = L_UINT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
.n.rank = RANK_UINT,
- .printed = 1
},
{ /* 18 = ellipsis */
.op = ELLIPSIS,
.letter = L_ELLIPSIS,
- .defined = 1,
- .printed = 1
+ .prop = TDEFINED | TPRINTED,
},
{ /* 19 = pdifftype */
.op = INT,
.letter = L_INT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
- .sign = 1,
.n.rank = RANK_LONG,
- .printed = 1
},
};
diff --git a/cc1/arch/i386-sysv/arch.c b/cc1/arch/i386-sysv/arch.c
@@ -17,212 +17,155 @@ static Type types[] = {
{ /* 0 = voidtype */
.op = VOID,
.letter = L_VOID,
- .printed = 1
+ .prop = TPRINTED,
},
{ /* 1 = pvoidtype */
.op = PTR,
.letter = L_POINTER,
+ .prop = TDEFINED | TPRINTED,
.size = 4,
.align = 4,
- .printed = 1,
- .defined = 1,
},
{ /* 2 = booltype */
.op = INT,
.letter = L_BOOL,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_BOOL,
- .printed = 1
},
{ /* 3 = schartype */
.op = INT,
.letter = L_INT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_SCHAR,
- .printed = 1
},
{ /* 4 = uchartype */
.op = INT,
.letter = L_UINT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_UCHAR,
- .printed = 1
},
{ /* 5 = chartype */
.op = INT,
.letter = L_INT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_CHAR,
- .printed = 1
},
{ /* 6 = ushortype */
.op = INT,
.letter = L_UINT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 2,
.n.rank = RANK_USHORT,
- .printed = 1
},
{ /* 7 = shortype */
.op = INT,
.letter = L_INT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 2,
- .sign = 1,
.n.rank = RANK_SHORT,
- .printed = 1
},
{ /* 8 = uinttype */
.op = INT,
.letter = L_UINT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
.n.rank = RANK_UINT,
- .printed = 1
},
{ /* 9 = inttype */
.op = INT,
.letter = L_INT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
- .sign = 1,
.n.rank = RANK_INT,
- .printed = 1
},
{ /* 10 = longtype */
.op = INT,
.letter = L_INT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
- .sign = 1,
.n.rank = RANK_LONG,
- .printed = 1
},
{ /* 11 = ulongtype */
.op = INT,
.letter = L_UINT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
.n.rank = RANK_ULONG,
- .printed = 1
},
{ /* 12 = ullongtype */
.op = INT,
.letter = L_UINT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 4,
.n.rank = RANK_ULLONG,
- .printed = 1
},
{ /* 13 = llongtype */
.op = INT,
.letter = L_INT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 4,
- .sign = 1,
.n.rank = RANK_LLONG,
- .printed = 1
},
{ /* 14 = floattype */
.op = FLOAT,
.letter = L_FLOAT,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 4,
- .arith = 1,
.align = 4,
.n.rank = RANK_FLOAT,
- .printed = 1
},
{ /* 15 = doubletype */
.op = FLOAT,
.letter = L_DOUBLE,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 8,
- .arith = 1,
.align = 4,
.n.rank = RANK_DOUBLE,
- .printed = 1
},
{ /* 16 = ldoubletype */
.op = FLOAT,
.letter = L_LDOUBLE,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 12,
- .arith = 1,
.align = 4,
.n.rank = RANK_LDOUBLE,
- .printed = 1
},
{ /* 17 = sizettype */
.op = INT,
.letter = L_UINT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
.n.rank = RANK_UINT,
- .printed = 1
},
{ /* 18 = ellipsis */
.op = ELLIPSIS,
.letter = L_ELLIPSIS,
- .defined = 1,
- .printed = 1
+ .prop = TDEFINED | TPRINTED,
},
{ /* 19 = pdifftype */
.op = INT,
.letter = L_INT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
- .sign = 1,
.n.rank = RANK_INT,
- .printed = 1
},
};
diff --git a/cc1/arch/qbe/arch.c b/cc1/arch/qbe/arch.c
@@ -17,212 +17,155 @@ static Type types[] = {
{ /* 0 = voidtype */
.op = VOID,
.letter = L_VOID,
- .printed = 1
+ .prop = TPRINTED,
},
{ /* 1 = pvoidtype */
.op = PTR,
.letter = L_POINTER,
+ .prop = TDEFINED | TPRINTED,
.size = 2,
.align = 2,
- .printed = 1,
- .defined = 1,
},
{ /* 2 = booltype */
.op = INT,
.letter = L_BOOL,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_BOOL,
- .printed = 1
},
{ /* 3 = schartype */
.op = INT,
.letter = L_INT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | SIGNED | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_SCHAR,
- .printed = 1
},
{ /* 4 = uchartype */
.op = INT,
.letter = L_UINT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_UCHAR,
- .printed = 1
},
{ /* 5 = chartype */
.op = INT,
.letter = L_INT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_CHAR,
- .printed = 1
},
{ /* 6 = ushortype */
.op = INT,
.letter = L_UINT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 2,
.n.rank = RANK_USHORT,
- .printed = 1
},
{ /* 7 = shortype */
.op = INT,
.letter = L_INT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 2,
- .sign = 1,
.n.rank = RANK_SHORT,
- .printed = 1
},
{ /* 8 = uinttype */
.op = INT,
.letter = L_UINT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
.n.rank = RANK_UINT,
- .printed = 1
},
{ /* 9 = inttype */
.op = INT,
.letter = L_INT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 4,
- .sign = 1,
.n.rank = RANK_INT,
- .printed = 1
},
{ /* 10 = longtype */
.op = INT,
.letter = L_INT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
- .sign = 1,
.n.rank = RANK_LONG,
- .printed = 1
},
{ /* 11 = ulongtype */
.op = INT,
.letter = L_UINT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
.n.rank = RANK_ULONG,
- .printed = 1
},
{ /* 12 = ullongtype */
.op = INT,
.letter = L_UINT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
.n.rank = RANK_ULLONG,
- .printed = 1
},
{ /* 13 = llongtype */
.op = INT,
.letter = L_INT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
- .sign = 1,
.n.rank = RANK_LLONG,
- .printed = 1
},
{ /* 14 = floattype */
.op = FLOAT,
.letter = L_FLOAT,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 4,
- .arith = 1,
.align = 4,
.n.rank = RANK_FLOAT,
- .printed = 1
},
{ /* 15 = doubletype */
.op = FLOAT,
.letter = L_DOUBLE,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 8,
- .arith = 1,
.align = 8,
.n.rank = RANK_DOUBLE,
- .printed = 1
},
{ /* 16 = ldoubletype */
.op = FLOAT,
.letter = L_LDOUBLE,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 16,
- .arith = 1,
.align = 16,
.n.rank = RANK_LDOUBLE,
- .printed = 1
},
{ /* 17 = sizettype */
.op = INT,
.letter = L_UINT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
.n.rank = RANK_UINT,
- .printed = 1
},
{ /* 18 = ellipsis */
.op = ELLIPSIS,
.letter = L_ELLIPSIS,
- .defined = 1,
- .printed = 1
+ .prop = TDEFINED | TPRINTED,
},
{ /* 19 = pdifftype */
.op = INT,
.letter = L_INT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 8,
- .sign = 1,
.n.rank = RANK_LONG,
- .printed = 1
},
};
diff --git a/cc1/arch/z80/arch.c b/cc1/arch/z80/arch.c
@@ -17,212 +17,155 @@ static Type types[] = {
{ /* 0 = voidtype */
.op = VOID,
.letter = L_VOID,
- .printed = 1
+ .prop = TPRINTED,
},
{ /* 1 = pvoidtype */
.op = PTR,
.letter = L_POINTER,
+ .prop = TDEFINED | TPRINTED,
.size = 2,
.align = 2,
- .printed = 1,
- .defined = 1,
},
{ /* 2 = booltype */
.op = INT,
.letter = L_BOOL,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_BOOL,
- .printed = 1
},
{ /* 3 = schartype */
.op = INT,
.letter = L_INT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_SCHAR,
- .printed = 1
},
{ /* 4 = uchartype */
.op = INT,
.letter = L_UINT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_UCHAR,
- .printed = 1
},
{ /* 5 = chartype */
.op = INT,
.letter = L_UINT8,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 1,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_CHAR,
- .printed = 1
},
{ /* 6 = ushortype */
.op = INT,
.letter = L_UINT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_USHORT,
- .printed = 1
},
{ /* 7 = shortype */
.op = INT,
.letter = L_INT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_SHORT,
- .printed = 1
},
{ /* 8 = uinttype */
.op = INT,
.letter = L_UINT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_UINT,
- .printed = 1
},
{ /* 9 = inttype */
.op = INT,
.letter = L_INT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_INT,
- .printed = 1
},
{ /* 10 = longtype */
.op = INT,
.letter = L_INT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_LONG,
- .printed = 1
},
{ /* 11 = ulongtype */
.op = INT,
.letter = L_UINT32,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 4,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_ULONG,
- .printed = 1
},
{ /* 12 = ullongtype */
.op = INT,
.letter = L_UINT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_ULLONG,
- .printed = 1
},
{ /* 13 = llongtype */
.op = INT,
.letter = L_INT64,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 8,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_LLONG,
- .printed = 1
},
{ /* 14 = floattype */
.op = FLOAT,
.letter = L_FLOAT,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 4,
- .arith = 1,
.align = 1,
.n.rank = RANK_FLOAT,
- .printed = 1
},
{ /* 15 = doubletype */
.op = FLOAT,
.letter = L_DOUBLE,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 8,
- .arith = 1,
.align = 1,
.n.rank = RANK_DOUBLE,
- .printed = 1
},
{ /* 16 = ldoubletype */
.op = FLOAT,
.letter = L_LDOUBLE,
- .defined = 1,
+ .prop = TDEFINED | TARITH | TPRINTED,
.size = 16,
- .arith = 1,
.align = 1,
.n.rank = RANK_LDOUBLE,
- .printed = 1
},
{ /* 17 = sizettype */
.op = INT,
.letter = L_UINT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 1,
.n.rank = RANK_UINT,
- .printed = 1
},
{ /* 18 = ellipsis */
.op = ELLIPSIS,
.letter = L_ELLIPSIS,
- .defined = 1,
- .printed = 1
+ .prop = TDEFINED | TPRINTED,
},
{ /* 7 = pdifftype */
.op = INT,
.letter = L_INT16,
- .defined = 1,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED | TPRINTED,
.size = 2,
- .integer = 1,
- .arith = 1,
.align = 1,
- .sign = 1,
.n.rank = RANK_SHORT,
- .printed = 1
},
};
diff --git a/cc1/cc1.h b/cc1/cc1.h
@@ -30,18 +30,22 @@ struct keyword {
unsigned char token, value;
};
+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 */
+};
+
struct type {
unsigned char op; /* type builder operator */
char ns; /* namespace for struct members */
short id; /* type id, used in dcls */
char letter; /* letter of the type */
- bool defined : 1; /* type defined */
- bool sign : 1; /* signess of the type */
- bool printed : 1; /* the type already was printed */
- bool integer : 1; /* this type is INT or enum */
- bool arith : 1; /* this type is INT, ENUM, FLOAT */
- bool aggreg : 1; /* this type is struct or union */
- bool k_r : 1; /* This is a k&r function */
+ enum typeprops prop; /* type properties */
TSIZE size; /* sizeof the type */
TSIZE align; /* align of the type */
Type *type; /* base type */
diff --git a/cc1/code.c b/cc1/code.c
@@ -194,7 +194,7 @@ emitconst(Node *np)
case PTR:
case INT:
case ENUM:
- u = (tp->sign) ? (TUINT) sym->u.i : sym->u.u;
+ u = (tp->prop & TSIGNED) ? (TUINT) sym->u.i : sym->u.u;
printf("#%c%llX",
np->type->letter,
(long long) sym->u.i & ones(tp->size));
@@ -240,9 +240,9 @@ emittype(Type *tp)
Symbol **sp;
char *tag;
- if (tp->printed || !tp->defined)
+ if ((tp->prop & TPRINTED) || !(tp->prop & TDEFINED))
return;
- tp->printed = 1;
+ tp->prop |= TPRINTED;
switch (tp->op) {
case ARY:
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -160,7 +160,7 @@ parameter(struct decl *dcl)
switch (tp->op) {
case VOID:
- if (n != 0 || funtp->k_r) {
+ if (n != 0 || (funtp->prop & TK_R)) {
errorp("incorrect void parameter");
return NULL;
}
@@ -177,11 +177,11 @@ parameter(struct decl *dcl)
}
if (!empty(sym, tp)) {
Symbol *p = install(NS_IDEN, sym);
- if (!p && !funtp->k_r) {
+ if (!p && !(funtp->prop & TK_R)) {
errorp("redefinition of parameter '%s'", name);
return NULL;
}
- if (p && funtp->k_r) {
+ if (p && (funtp->prop & TK_R)) {
errorp("declaration for parameter ‘%s’ but no such parameter",
sym->name);
return NULL;
@@ -287,7 +287,7 @@ fundcl(struct declarators *dp)
pushctx();
expect('(');
type.n.elem = 0;
- type.k_r = 0;
+ type.prop = 0;
k_r = (yytoken == ')' || yytoken == IDEN);
(*(k_r ? krfun : ansifun))(&type, types, syms, &ntypes, &nsyms);
@@ -518,9 +518,9 @@ structdcl(void)
return tp;
}
- if (tp->defined)
+ if (tp->prop & TDEFINED)
error("redefinition of struct/union '%s'", sym->name);
- tp->defined = 1;
+ tp->prop |= TDEFINED;
if (nested == NR_STRUCT_LEVEL)
error("too many levels of nested structure or union definitions");
@@ -551,9 +551,9 @@ enumdcl(void)
if (!accept('{'))
goto restore_name;
- if (tp->defined)
+ if (tp->prop & TDEFINED)
errorp("redefinition of enumeration '%s'", tagsym->name);
- tp->defined = 1;
+ tp->prop |= TDEFINED;
namespace = NS_IDEN;
/* TODO: check incorrect values in val */
@@ -626,7 +626,7 @@ field(struct decl *dcl)
errorp("storage class in struct/union field");
err = 1;
}
- if (!tp->defined) {
+ if (!(tp->prop & TDEFINED)) {
error("field '%s' has incomplete type", name);
err = 1;
}
@@ -729,7 +729,7 @@ identifier(struct decl *dcl)
return sym;
/* TODO: Add warning about ANSI limits */
- if (!tp->defined &&
+ if (!(tp->prop & TDEFINED) &&
sclass != EXTERN && sclass != TYPEDEF &&
!(tp->op == ARY && yytoken == '=')) {
errorp("declared variable '%s' of incomplete type", name);
@@ -860,7 +860,7 @@ decl(void)
curfun = ocurfun;
return;
}
- if (sym->type->k_r) {
+ if (sym->type->prop & TK_R) {
while (yytoken != '{') {
par = dodcl(1, parameter, NS_IDEN, sym->type);
expect(';');
diff --git a/cc1/expr.c b/cc1/expr.c
@@ -28,7 +28,7 @@ cmpnode(Node *np, TUINT val)
case PTR:
case INT:
mask = (val > 1) ? ones(np->type->size) : -1;
- nodeval = (tp->sign) ? sym->u.i : sym->u.u;
+ nodeval = (tp->prop & TSIGNED) ? sym->u.i : sym->u.u;
return (nodeval & mask) == (val & mask);
case FLOAT:
return sym->u.f == val;
@@ -100,8 +100,13 @@ arithconv(Node **p1, Node **p2)
if (tp1 == tp2)
goto set_p1_p2;
- s1 = tp1->sign, r1 = tp1->n.rank, lp1 = getlimits(tp1);
- s2 = tp2->sign, r2 = tp2->n.rank, lp2 = getlimits(tp2);
+ s1 = (tp1->prop & TSIGNED) != 0;
+ r1 = tp1->n.rank;
+ lp1 = getlimits(tp1);
+
+ s2 = (tp2->prop & TSIGNED) != 0;
+ r2 = tp2->n.rank;
+ lp2 = getlimits(tp2);
if (s1 == s2 || tp1->op == FLOAT || tp2->op == FLOAT) {
to = r1 - r2;
@@ -149,15 +154,15 @@ chkternary(Node *yes, Node *no)
*/
if (!eqtype(yes->type, no->type)) {
- if (yes->type->arith && no->type->arith) {
+ if ((yes->type->prop & TARITH) && (no->type->prop & TARITH)) {
arithconv(&yes, &no);
} else if (yes->type->op != PTR && no->type->op != PTR) {
goto wrong_type;
} else {
/* convert integer 0 to NULL */
- if (yes->type->integer && cmpnode(yes, 0))
+ if ((yes->type->prop & TINTEGER) && cmpnode(yes, 0))
yes = convert(yes, pvoidtype, 0);
- if (no->type->integer && cmpnode(no, 0))
+ if ((no->type->prop & TINTEGER) && cmpnode(no, 0))
no = convert(no, pvoidtype, 0);
/*
* At this point the type of both should be
@@ -225,7 +230,7 @@ decay(Node *np)
static Node *
integerop(char op, Node *lp, Node *rp)
{
- if (!lp->type->integer || !rp->type->integer)
+ if (!(lp->type->prop & TINTEGER) || !(rp->type->prop & TINTEGER))
error("operator requires integer operands");
arithconv(&lp, &rp);
return simplify(op, lp->type, lp, rp);
@@ -234,7 +239,7 @@ integerop(char op, Node *lp, Node *rp)
static Node *
integeruop(char op, Node *np)
{
- if (!np->type->integer)
+ if (!(np->type->prop & TINTEGER))
error("unary operator requires integer operand");
np = promote(np);
if (op == OCPL && np->op == OCPL)
@@ -245,7 +250,7 @@ integeruop(char op, Node *np)
static Node *
numericaluop(char op, Node *np)
{
- if (!np->type->arith)
+ if (!(np->type->prop & TARITH))
error("unary operator requires numerical operand");
np = promote(np);
if (op == ONEG && np->op == ONEG)
@@ -321,7 +326,7 @@ parithmetic(char op, Node *lp, Node *rp)
lp = node(OSUB, pdifftype, lp, rp);
return node(ODIV, inttype, lp, size);
}
- if (!rp->type->integer)
+ if (!(rp->type->prop & TINTEGER))
goto incorrect;
rp = convert(promote(rp), sizettype, 0);
@@ -340,7 +345,7 @@ arithmetic(char op, Node *lp, Node *rp)
{
Type *ltp = lp->type, *rtp = rp->type;
- if (ltp->arith && rtp->arith) {
+ if ((ltp->prop & TARITH) && (rtp->prop & TARITH)) {
arithconv(&lp, &rp);
} else if ((ltp->op == PTR || rtp->op == PTR) &&
(op == OADD || op == OSUB)) {
@@ -357,10 +362,10 @@ pcompare(char op, Node *lp, Node *rp)
Node *np;
int err = 0;
- if (lp->type->integer)
+ if (lp->type->prop & TINTEGER)
XCHG(lp, rp, np);
- if (rp->type->integer) {
+ if (rp->type->prop & TINTEGER) {
if (!cmpnode(rp, 0))
err = 1;
rp = convert(rp, pvoidtype, 1);
@@ -388,7 +393,7 @@ compare(char op, Node *lp, Node *rp)
if (ltp->op == PTR || rtp->op == PTR) {
return pcompare(op, rp, lp);
- } else if (ltp->arith && rtp->arith) {
+ } else if ((ltp->prop & TARITH) && (rtp->prop & TARITH)) {
arithconv(&lp, &rp);
return simplify(op, inttype, lp, rp);
} else {
@@ -426,7 +431,7 @@ static Node *
exp2cond(Node *np, char neg)
{
np = decay(np);
- if (np->type->aggreg) {
+ if (np->type->prop & TAGGREG) {
errorp("used struct/union type value where scalar is required");
np = constnode(zero);
}
@@ -457,7 +462,7 @@ field(Node *np)
unexpected();
next();
- if (!np->type->aggreg) {
+ if (!(np->type->prop & TAGGREG)) {
errorp("request for member '%s' in something not a structure or union",
yylval.sym->name);
goto free_np;
@@ -504,7 +509,7 @@ array(Node *lp, Node *rp)
Type *tp;
Node *np;
- if (!lp->type->integer && !rp->type->integer)
+ if (!(lp->type->prop & TINTEGER) && !(rp->type->prop & TINTEGER))
error("array subscript is not an integer");
np = arithmetic(OADD, decay(lp), decay(rp));
tp = np->type;
@@ -533,10 +538,10 @@ incdec(Node *np, char op)
chklvalue(np);
np->flags |= NEFFECT;
- if (!tp->defined) {
+ if (!(tp->prop & TDEFINED)) {
errorp("invalid use of undefined type");
return np;
- } else if (tp->arith) {
+ } else if (tp->prop & TARITH) {
inc = constnode(one);
} else if (tp->op == PTR) {
inc = sizeofnode(tp->type);
@@ -573,7 +578,7 @@ static Node *
negation(char op, Node *np)
{
np = decay(np);
- if (!np->type->arith && np->type->op != PTR) {
+ if (!(np->type->prop & TARITH) && np->type->op != PTR) {
errorp("invalid argument of unary '!'");
freetree(np);
return constnode(zero);
@@ -795,7 +800,7 @@ unary(void)
case SIZEOF:
next();
tp = (yytoken == '(') ? sizeexp() : typeof(unary());
- if (!tp->defined)
+ if (!(tp->prop & TDEFINED))
errorp("sizeof applied to an incomplete type");
return sizeofnode(tp);
case INC:
diff --git a/cc1/fold.c b/cc1/fold.c
@@ -335,7 +335,7 @@ fold(int op, Type *tp, Node *lp, Node *rp)
switch (type = optype->op) {
case ENUM:
case INT:
- if (!optype->sign)
+ if (!(optype->prop & TSIGNED))
type = UNSIGNED;
case PTR:
case FLOAT:
@@ -549,7 +549,7 @@ castcode(Node *np, Type *newtp)
case PTR:
case INT:
case ENUM:
- u = (oldtp->sign) ? osym->u.i : osym->u.u;
+ u = (oldtp->prop & TSIGNED) ? osym->u.i : osym->u.u;
break;
case FLOAT:
oldtp = newtp;
@@ -559,7 +559,7 @@ castcode(Node *np, Type *newtp)
goto noconstant;
}
mask = ones(newtp->size);
- if (newtp->sign) {
+ if (newtp->prop & TSIGNED) {
negmask = ~mask;
if (u & (negmask >> 1) & mask)
u |= negmask;
@@ -570,7 +570,7 @@ castcode(Node *np, Type *newtp)
break;
case FLOAT:
/* FIXME: The cast can be from another float type */
- aux.u.f = (oldtp->sign) ? osym->u.i : osym->u.u;
+ aux.u.f = (oldtp->prop & TSIGNED) ? osym->u.i : osym->u.u;
break;
default:
goto noconstant;
diff --git a/cc1/init.c b/cc1/init.c
@@ -39,7 +39,7 @@ arydesig(Init *ip)
next();
np = iconstexpr();
npos = np->sym->u.i;
- if (npos < 0 || tp->defined && npos >= tp->n.elem) {
+ if (npos < 0 || (tp->prop & TDEFINED) && npos >= tp->n.elem) {
errorp("array index in initializer exceeds array bounds");
npos = 0;
}
@@ -55,7 +55,7 @@ fielddesig(Init *ip)
Symbol *sym, **p;
Type *tp = ip->type;
- if (!tp->aggreg)
+ if (!(tp->prop & TAGGREG))
errorp("field name not in record or union initializer");
ons = namespace;
namespace = tp->ns;
@@ -119,8 +119,8 @@ initialize(Type *tp)
goto return_zero;
}
len = sym->type->n.elem-1;
- if (!tp->defined) {
- tp->defined = 1;
+ if (!(tp->prop & TDEFINED)) {
+ tp->prop |= TDEFINED;
tp->n.elem = len+1;
} else if (tp->n.elem < len) {
warn("initializer-string for array of chars is too long");
@@ -221,7 +221,7 @@ initlist(Type *tp)
switch (tp->op) {
case ARY:
newtp = tp->type;
- if (!tp->defined || in.pos < tp->n.elem)
+ if (!(tp->prop & TDEFINED) || in.pos < tp->n.elem)
break;
if (!toomany)
warn("excess elements in array initializer");
@@ -271,9 +271,9 @@ initlist(Type *tp)
if (braces)
expect('}');
- if (tp->op == ARY && !tp->defined) {
+ if (tp->op == ARY && !(tp->prop & TDEFINED)) {
tp->n.elem = in.max;
- tp->defined = 1;
+ tp->prop |= TDEFINED;
}
if (tp->op == ARY || tp->op == STRUCT)
in.max = tp->n.elem;
diff --git a/cc1/lex.c b/cc1/lex.c
@@ -278,7 +278,7 @@ readint(char *s, int base, int sign, Symbol *sym)
repeat:
if (u <= max/base && u*base <= max - val)
continue;
- if (tp->sign) {
+ if (tp->prop & TSIGNED) {
if (tp == inttype)
tp = (base==10) ? longtype : uinttype;
else if (tp == longtype)
@@ -299,7 +299,7 @@ readint(char *s, int base, int sign, Symbol *sym)
goto repeat;
}
- if (tp->sign)
+ if (tp->prop & TSIGNED)
sym->u.i = u;
else
sym->u.u = u;
diff --git a/cc1/symbol.c b/cc1/symbol.c
@@ -86,7 +86,7 @@ killsym(Symbol *sym)
if (f & SSTRING)
free(sym->u.s);
if (sym->ns == NS_TAG)
- sym->type->defined = 0;
+ sym->type->prop &= ~TDEFINED;
unlinkhash(sym);
if ((name = sym->name) != NULL && sym->ns != NS_CPP) {
if ((f & (SUSED|SGLOBAL|SDECLARED)) == SDECLARED)
diff --git a/cc1/types.c b/cc1/types.c
@@ -81,7 +81,7 @@ getlimits(Type *tp)
switch (tp->op) {
case ENUM:
case INT:
- ntable = tp->sign;
+ ntable = ((tp->prop & TSIGNED) != 0);
switch (tp->size) {
case 1: ntype = 0; break;
case 2: ntype = 1; break;
@@ -259,13 +259,7 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[])
type.type = tp;
type.op = op;
- type.defined = 0;
- type.arith = 0;
- type.sign = 0;
- type.integer = 0;
- type.printed = 0;
- type.aggreg = 0;
- type.k_r = k_r;
+ type.prop = k_r ? TK_R : 0;
type.letter = c;
type.p.pars = pars;
type.n.elem = nelem;
@@ -278,17 +272,15 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[])
/* PASSTROUGH */
case FTN:
case PTR:
- type.defined = 1;
+ type.prop |= TDEFINED;
break;
case ENUM:
- type.printed = 1;
- type.integer = 1;
- type.arith = 1;
+ type.prop |= TPRINTED | TINTEGER | TARITH;
type.n.rank = RANK_INT;
break;
case STRUCT:
case UNION:
- type.aggreg = 1;
+ type.prop |= TAGGREG;
break;
}