shithub: scc

Download patch

ref: d72d86eb7ab39320fcd33642458862aff84bdc3b
parent: beac8a2f180a7bb9941b20f39339d12d2b5582c9
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue May 12 05:02:26 EDT 2015

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.

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -207,7 +207,6 @@
 	OASK,
 	OCOLON,
 	OFIELD,
-	OTYP,
 	OLABEL,
 	ODEFAULT,
 	OCASE,
@@ -276,6 +275,7 @@
 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 */
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -353,3 +353,12 @@
 	np->sym = sym;
 	return np;
 }
+
+Node *
+sizeofnode(Type *tp)
+{
+	Node *np;
+
+	np = node(0, tp, NULL, NULL);
+	return node(OSIZE, inttype, np, NULL);
+}
--- 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 @@
 	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 @@
 	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 @@
 	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();