shithub: scc

Download patch

ref: 73e8f02ee56e42272698ef92ec8b593cec130843
parent: 0c5e2751bdf1b8db6700733e84b2887f7f38aabc
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Jul 24 10:10:55 EDT 2015

Use BTYPE instead of np->type->op

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -327,6 +327,7 @@
 extern Node *sizeofnode(Type *tp);
 extern void freetree(Node *np);
 extern Node *simplify(unsigned char, Type *tp, Node *lp, Node *rp);
+#define BTYPE(np) ((np)->type->op)
 
 /* expr.c */
 extern Node *expr(void), *negate(Node *np), *constexpr(void);
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -183,7 +183,7 @@
 	char *bp, c;
 	Symbol *sym = np->sym;
 
-	switch (np->type->op) {
+	switch (BTYPE(np)) {
 	case INT:
 		printf("#%c%x", np->type->letter, sym->u.i);
 		break;
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -6,8 +6,6 @@
 #include "../inc/cc.h"
 #include "cc1.h"
 
-#define BTYPE(np) ((np)->type->op)
-
 extern Symbol *zero, *one;
 
 Node *expr(void);
@@ -377,7 +375,7 @@
 static Node *
 assignop(char op, Node *lp, Node *rp)
 {
-	switch (rp->type->op) {
+	switch (BTYPE(rp)) {
 	case FTN:
 	case ARY:
 		rp = decay(rp);
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -219,7 +219,7 @@
 	expect(SWITCH);
 	expect ('(');
 	cond = expr();
-	if (cond->type->op != INT)
+	if (BTYPE(cond) != INT)
 		error("incorrect type in switch statement");
 	cond = convert(cond, inttype, 0);
 	expect (')');