scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit ea94f2eb1475cf3f96b3d9d274e2e23f05924142
parent e5149360ecf4c42b45c0992ae7a31e8c20a75869
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  4 Nov 2022 07:24:05 +0100

cc1: Remove magic numbers with eqtype()

Diffstat:
Msrc/cmd/cc/cc1/amd64-sysv.c | 2+-
Msrc/cmd/cc/cc1/arm64-sysv.c | 2+-
Msrc/cmd/cc/cc1/cc1.h | 3+++
Msrc/cmd/cc/cc1/decl.c | 2+-
Msrc/cmd/cc/cc1/expr.c | 8++++----
Msrc/cmd/cc/cc1/i386-sysv.c | 2+-
Msrc/cmd/cc/cc1/init.c | 2+-
Msrc/cmd/cc/cc1/types.c | 2+-
Msrc/cmd/cc/cc1/z80-scc.c | 2+-
9 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/cmd/cc/cc1/amd64-sysv.c b/src/cmd/cc/cc1/amd64-sysv.c @@ -20,7 +20,7 @@ static int local_valid_va_list(Type *tp) { - return tp->op == PTR && eqtype(tp->type, va_type, 1); + return tp->op == PTR && eqtype(tp->type, va_type, EQUIV); } Arch * diff --git a/src/cmd/cc/cc1/arm64-sysv.c b/src/cmd/cc/cc1/arm64-sysv.c @@ -20,7 +20,7 @@ static int local_valid_va_list(Type *tp) { - return tp->op == PTR && eqtype(tp->type, va_type, 1); + return tp->op == PTR && eqtype(tp->type, va_type, EQUIV); } Arch * diff --git a/src/cmd/cc/cc1/cc1.h b/src/cmd/cc/cc1/cc1.h @@ -8,6 +8,9 @@ #define FAIL 1 #define NOFAIL 0 +#define EQUAL 0 +#define EQUIV 1 + /* * Definition of enumerations */ diff --git a/src/cmd/cc/cc1/decl.c b/src/cmd/cc/cc1/decl.c @@ -187,7 +187,7 @@ redcl(Symbol *sym, Type *tp, int sclass) int flags; char *name = sym->name; - if (!eqtype(sym->type, tp, 1)) { + if (!eqtype(sym->type, tp, EQUIV)) { errorp("conflicting types for '%s'", name); return sym; } diff --git a/src/cmd/cc/cc1/expr.c b/src/cmd/cc/cc1/expr.c @@ -140,7 +140,7 @@ chkternary(Node *yes, Node *no) * take a look to 6.5.15 */ - if (!eqtype(yes->type, no->type, 1)) { + if (!eqtype(yes->type, no->type, EQUIV)) { if ((yes->type->prop & TARITH) && (no->type->prop & TARITH)) { arithconv(&yes, &no); } else if (yes->type->op != PTR && no->type->op != PTR) { @@ -167,7 +167,7 @@ chkternary(Node *yes, Node *no) if (null(no)) no = convert(no, yes->type, 0); - if (!eqtype(yes->type, no->type, 1)) + if (!eqtype(yes->type, no->type, EQUIV)) goto wrong_type; } } @@ -254,7 +254,7 @@ convert(Node *np, Type *newtp, int iscast) Type *oldtp = np->type; int op = newtp->op; - if (eqtype(newtp, oldtp, 0)) + if (eqtype(newtp, oldtp, EQUAL)) return np; if (iscast && op == VOID) goto good_conv; @@ -273,7 +273,7 @@ convert(Node *np, Type *newtp, int iscast) if (iscast) goto good_conv; } else if (op == PTR) { - if (eqtype(newtp, oldtp, 1)) + if (eqtype(newtp, oldtp, EQUIV)) goto good_conv; if (iscast) goto good_conv; diff --git a/src/cmd/cc/cc1/i386-sysv.c b/src/cmd/cc/cc1/i386-sysv.c @@ -20,7 +20,7 @@ static int local_valid_va_list(Type *tp) { - return eqtype(tp, va_list_type, 1); + return eqtype(tp, va_list_type, EQUIV); } Arch * diff --git a/src/cmd/cc/cc1/init.c b/src/cmd/cc/cc1/init.c @@ -123,7 +123,7 @@ initialize(Type *tp) return initlist(tp); np = assign(); - if (eqtype(tp, np->type, 1)) + if (eqtype(tp, np->type, EQUIV)) return np; np = convert(decay(np), tp, 0); diff --git a/src/cmd/cc/cc1/types.c b/src/cmd/cc/cc1/types.c @@ -342,7 +342,7 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[]) tbl = &typetab[HASH(&type)]; for (bp = *tbl; bp; bp = bp->h_next) { - if (eqtype(bp, &type, 0)) + if (eqtype(bp, &type, EQUAL)) return bp; } diff --git a/src/cmd/cc/cc1/z80-scc.c b/src/cmd/cc/cc1/z80-scc.c @@ -20,7 +20,7 @@ static int local_valid_va_list(Type *tp) { - return eqtype(tp, va_list_type, 1); + return eqtype(tp, va_list_type, EQUIV); } Arch *