From 8e5145949ba477fd49f1e541b8ed1341d4c3bb69 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sun, 2 Jan 2022 14:37:25 -0800 Subject: Remove unused type properties --- cc.h | 15 ++++++--------- decl.c | 6 ++---- expr.c | 4 ++-- targ.c | 8 ++++---- type.c | 10 +++++----- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/cc.h b/cc.h index 6f23b86..3a877ea 100644 --- a/cc.h +++ b/cc.h @@ -163,15 +163,12 @@ enum typekind { enum typeprop { PROPNONE, - PROPOBJECT = 1<<0, - PROPCHAR = 1<<1, - PROPINT = 1<<2, - PROPREAL = 1<<3, - PROPARITH = 1<<4, - PROPSCALAR = 1<<5, - PROPAGGR = 1<<6, - PROPDERIVED = 1<<7, - PROPFLOAT = 1<<8 + PROPCHAR = 1<<0, + PROPINT = 1<<1, + PROPREAL = 1<<2, + PROPARITH = 1<<3, + PROPSCALAR = 1<<4, + PROPFLOAT = 1<<5 }; struct param { diff --git a/decl.c b/decl.c index fd1745c..7f57dc8 100644 --- a/decl.c +++ b/decl.c @@ -179,9 +179,7 @@ tagspec(struct scope *s) *t = typeuint; t->kind = kind; } else { - t = mktype(kind, PROPOBJECT); - if (kind == TYPESTRUCT) - t->prop |= PROPAGGR; + t = mktype(kind, 0); t->size = 0; t->align = 0; t->u.structunion.tag = tag; @@ -507,7 +505,7 @@ declaratortypes(struct scope *s, struct list *result, char **name, bool allowabs case TLPAREN: /* function declarator */ next(); func: - t = mktype(TYPEFUNC, PROPDERIVED); + t = mktype(TYPEFUNC, 0); t->qual = QUALNONE; t->u.func.isprototype = false; t->u.func.isvararg = false; diff --git a/expr.c b/expr.c index 9437b33..ca0aacd 100644 --- a/expr.c +++ b/expr.c @@ -262,7 +262,7 @@ mkbinaryexpr(struct location *loc, enum tokenkind op, struct expr *l, struct exp if (l->type->kind != TYPEPOINTER || !(rp & PROPINT)) error(loc, "invalid operands to '+' operator"); t = l->type; - if (t->base->incomplete || !(t->base->prop & PROPOBJECT)) + if (t->base->incomplete || t->base->kind == TYPEFUNC) error(loc, "pointer operand to '+' must be to complete object type"); r = mkbinaryexpr(loc, TMUL, exprconvert(r, &typeulong), mkconstexpr(&typeulong, t->base->size)); break; @@ -273,7 +273,7 @@ mkbinaryexpr(struct location *loc, enum tokenkind op, struct expr *l, struct exp } if (l->type->kind != TYPEPOINTER || !(rp & PROPINT) && r->type->kind != TYPEPOINTER) error(loc, "invalid operands to '-' operator"); - if (l->type->base->incomplete || !(l->type->base->prop & PROPOBJECT)) + if (l->type->base->incomplete || l->type->base->kind == TYPEFUNC) error(loc, "pointer operand to '-' must be to complete object type"); if (rp & PROPINT) { t = l->type; diff --git a/targ.c b/targ.c index 7e43555..2ffcd3e 100644 --- a/targ.c +++ b/targ.c @@ -10,10 +10,10 @@ static const struct target alltargs[] = { .name = "x86_64", .typewchar = &typeint, .typevalist = &(struct type){ - .kind = TYPEARRAY, .prop = PROPOBJECT|PROPDERIVED|PROPAGGR, + .kind = TYPEARRAY, .align = 8, .size = 24, .u.array = {1}, .base = &(struct type){ - .kind = TYPESTRUCT, .prop = PROPOBJECT|PROPAGGR, + .kind = TYPESTRUCT, .align = 8, .size = 24, }, }, @@ -22,7 +22,7 @@ static const struct target alltargs[] = { { .name = "aarch64", .typevalist = &(struct type){ - .kind = TYPESTRUCT, .prop = PROPOBJECT|PROPAGGR, + .kind = TYPESTRUCT, .align = 8, .size = 32, .u.structunion.tag = "va_list", }, @@ -31,7 +31,7 @@ static const struct target alltargs[] = { { .name = "riscv64", .typevalist = &(struct type){ - .kind = TYPEPOINTER, .prop = PROPOBJECT|PROPDERIVED|PROPSCALAR, + .kind = TYPEPOINTER, .prop = PROPSCALAR, .align = 8, .size = 8, .base = &typevoid, }, diff --git a/type.c b/type.c index b3453b9..563b3bf 100644 --- a/type.c +++ b/type.c @@ -8,14 +8,14 @@ #define INTTYPE(k, n, s, p) { \ .kind = k, .size = n, .align = n, .u.basic.issigned = s, \ - .prop = PROPOBJECT|PROPSCALAR|PROPARITH|PROPREAL|PROPINT|p, \ + .prop = PROPSCALAR|PROPARITH|PROPREAL|PROPINT|p, \ } #define FLTTYPE(k, n) { \ .kind = k, .size = n, .align = n, \ - .prop = PROPOBJECT|PROPSCALAR|PROPARITH|PROPREAL|PROPFLOAT, \ + .prop = PROPSCALAR|PROPARITH|PROPREAL|PROPFLOAT, \ } -struct type typevoid = {.kind = TYPEVOID, .prop = PROPOBJECT, .incomplete = true}; +struct type typevoid = {.kind = TYPEVOID, .incomplete = true}; struct type typebool = INTTYPE(TYPEBOOL, 1, false, 0); @@ -61,7 +61,7 @@ mkpointertype(struct type *base, enum typequal qual) { struct type *t; - t = mktype(TYPEPOINTER, PROPOBJECT|PROPDERIVED|PROPSCALAR); + t = mktype(TYPEPOINTER, PROPSCALAR); t->base = base; t->qual = qual; t->size = 8; @@ -75,7 +75,7 @@ mkarraytype(struct type *base, enum typequal qual, unsigned long long len) { struct type *t; - t = mktype(TYPEARRAY, PROPOBJECT|PROPDERIVED|PROPAGGR); + t = mktype(TYPEARRAY, 0); t->base = base; t->qual = qual; t->u.array.length = len; -- cgit v1.2.3