scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 73e8f02ee56e42272698ef92ec8b593cec130843
parent 0c5e2751bdf1b8db6700733e84b2887f7f38aabc
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 24 Jul 2015 14:10:55 +0200

Use BTYPE instead of np->type->op

Diffstat:
Mcc1/cc1.h | 1+
Mcc1/code.c | 2+-
Mcc1/expr.c | 4+---
Mcc1/stmt.c | 2+-
4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -327,6 +327,7 @@ extern Node *constnode(Symbol *sym); 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); diff --git a/cc1/code.c b/cc1/code.c @@ -183,7 +183,7 @@ emitconst(Node *np) 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; diff --git 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 @@ iszero(Node *np) static Node * assignop(char op, Node *lp, Node *rp) { - switch (rp->type->op) { + switch (BTYPE(rp)) { case FTN: case ARY: rp = decay(rp); diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -219,7 +219,7 @@ Switch(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) 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 (')');