commit d72d86eb7ab39320fcd33642458862aff84bdc3b
parent beac8a2f180a7bb9941b20f39339d12d2b5582c9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 12 May 2015 09:02:26 +0200
Remove TYPE(tp) macro
There is also another macro called TYPE, but without arguments. GCC,
fails in detect the redefinition, but other compiler cannot fail.
Diffstat:
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/cc1/cc1.h b/cc1/cc1.h
@@ -207,7 +207,6 @@ enum {
OASK,
OCOLON,
OFIELD,
- OTYP,
OLABEL,
ODEFAULT,
OCASE,
@@ -276,6 +275,7 @@ extern void emit(uint8_t, void *);
extern Node *node(uint8_t op, Type *tp, Node *left, Node *rigth);
extern Node *varnode(Symbol *sym);
extern Node *constnode(Symbol *sym);
+extern Node *sizeofnode(Type *tp);
extern void freetree(Node *np);
/* expr.c */
diff --git a/cc1/code.c b/cc1/code.c
@@ -353,3 +353,12 @@ constnode(Symbol *sym)
np->sym = sym;
return np;
}
+
+Node *
+sizeofnode(Type *tp)
+{
+ Node *np;
+
+ np = node(0, tp, NULL, NULL);
+ return node(OSIZE, inttype, np, NULL);
+}
diff --git a/cc1/expr.c b/cc1/expr.c
@@ -7,7 +7,6 @@
#include "cc1.h"
#define BTYPE(np) ((np)->type->op)
-#define TYPE(tp) node(OTYP, (tp), NULL, NULL)
extern Symbol *zero, *one;
@@ -167,7 +166,7 @@ parithmetic(char op, Node *lp, Node *rp)
Node *size;
tp = lp->type;
- size = node(OSIZE, inttype, TYPE(tp->type), NULL);
+ size = sizeofnode(tp->type);
if (BTYPE(rp) == ARY)
rp = decay(rp);
@@ -399,7 +398,7 @@ incdec(Node *np, char op)
case PTR:
if (!tp->defined)
error("invalid use of indefined type");
- inc = node(OSIZE, inttype, TYPE(tp->type), NULL);
+ inc = sizeofnode(tp->type);
break;
case INT:
case FLOAT:
@@ -584,7 +583,7 @@ unary(void)
case SIZEOF:
next();
tp = (yytoken == '(') ? sizeexp() : typeof(unary());
- return node(OSIZE, inttype, TYPE(tp), NULL);
+ return sizeofnode(tp);
case INC: case DEC:
op = (yytoken == INC) ? OA_ADD : OA_SUB;
next();