ref: 624848780072de338c258596833708934bed9204
parent: e06a619d7769dc7e2081c1ede01949991041b3a5
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jan 7 14:00:46 EST 2016
Add arith and integer flags to type These flags help in the code, because they can simplify a lot some of the conditions where we are using complex switches.
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -42,6 +42,8 @@
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 */
size_t size; /* sizeof the type */
size_t align; /* align of the type */
Type *type; /* base type */
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -97,6 +97,8 @@
.letter = L_BOOL,
.defined = 1,
.size = 1,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.n.rank = RANK_BOOL,
.printed = 1
@@ -106,6 +108,8 @@
.letter = L_SCHAR,
.defined = 1,
.size = 1,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.sign = 1,
.n.rank = RANK_SCHAR,
@@ -116,6 +120,8 @@
.letter = L_UCHAR,
.defined = 1,
.size = 1,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.n.rank = RANK_UCHAR,
.printed = 1
@@ -125,6 +131,8 @@
.letter = L_CHAR,
.defined = 1,
.size = 1,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.sign = 1,
.n.rank = RANK_CHAR,
@@ -135,6 +143,8 @@
.letter = L_USHORT,
.defined = 1,
.size = 2,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.n.rank = RANK_USHORT,
.printed = 1
@@ -144,6 +154,8 @@
.letter = L_SHORT,
.defined = 1,
.size = 2,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.sign = 1,
.n.rank = RANK_SHORT,
@@ -154,6 +166,8 @@
.letter = L_UINT,
.defined = 1,
.size = 2,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.n.rank = RANK_UINT,
.printed = 1
@@ -163,6 +177,8 @@
.letter = L_INT,
.defined = 1,
.size = 2,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.sign = 1,
.n.rank = RANK_INT,
@@ -173,6 +189,8 @@
.letter = L_LONG,
.defined = 1,
.size = 4,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.sign = 1,
.n.rank = RANK_LONG,
@@ -183,6 +201,8 @@
.letter = L_ULONG,
.defined = 1,
.size = 4,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.n.rank = RANK_ULONG,
.printed = 1
@@ -192,6 +212,8 @@
.letter = L_ULLONG,
.defined = 1,
.size = 8,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.n.rank = RANK_ULLONG,
.printed = 1
@@ -201,6 +223,8 @@
.letter = L_LLONG,
.defined = 1,
.size = 8,
+ .integer = 1,
+ .arith = 1,
.align = 1,
.sign = 1,
.n.rank = RANK_LLONG,
@@ -211,6 +235,7 @@
.letter = L_FLOAT,
.defined = 1,
.size = 4,
+ .arith = 1,
.align = 1,
.n.rank = RANK_FLOAT,
.printed = 1
@@ -220,6 +245,7 @@
.letter = L_DOUBLE,
.defined = 1,
.size = 8,
+ .arith = 1,
.align = 1,
.n.rank = RANK_DOUBLE,
.printed = 1
@@ -229,6 +255,7 @@
.letter = L_LDOUBLE,
.defined = 1,
.size = 16,
+ .arith = 1,
.align = 1,
.n.rank = RANK_LDOUBLE,
.printed = 1
@@ -436,6 +463,8 @@
break;
case ENUM:
type.printed = 1;
+ type.integer = 1;
+ type.arith = 1;
/* PASSTROUGH */
case STRUCT:
case UNION: