commit d1c3a0d77670defbdac8bc39a5182170934d8063
parent 813b9848feb7c50708fee6fd00f006a85ca4779e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 30 Mar 2014 20:25:37 +0200
Fix bool type
It is easier considerer bool as int with size 0.
Diffstat:
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/expr.c b/expr.c
@@ -56,9 +56,9 @@ add(Node *np1, Node *np2)
t1 = tp1->op, t2 = tp2->op;
switch (t1) {
- case BOOL: case INT:
+ case INT:
switch (t2) {
- case BOOL: case INT:
+ case INT:
if (tp1 != tp2)
intconv(&np1, &np2);
break;
@@ -79,7 +79,7 @@ add(Node *np1, Node *np2)
if (tp1 != tp2)
floatconv(&np1, &np2);
break;
- case BOOL: case INT:
+ case INT:
int_float: np2 = unarycode(OCAST, np1->type, np2);
break;
default:
diff --git a/types.c b/types.c
@@ -13,6 +13,9 @@ Type
*voidtype = &(Type) {
.op = VOID
},
+ *booltype = &(Type) {
+ .op = INT,
+ },
*uchartype = &(Type) {
.op = INT,
.size = CHARSIZE,
@@ -38,7 +41,7 @@ Type
},
*shortype = &(Type) {
.op = INT,
- .size = INTSIZE,
+ .size = SHORTSIZE,
},
*longtype = &(Type) {
.op = INT,
@@ -113,6 +116,7 @@ ctype(int8_t type, int8_t sign, int8_t size, int8_t cplex)
switch (type) {
case VOID: return voidtype;
+ case BOOL: return booltype;
case CHAR: return (sign) ? uchartype : chartype;
case INT: switch (size) {
case 0: return (sign) ? uinttype : inttype;