ref: 11f2fad7a2d1dfb01db4048b86f48c9762909587
parent: ac2bbe2c9e6a192cb7009a85f3801fc8c8e772aa
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jan 7 14:20:17 EST 2016
Convert integerop(), numericaluop() and integeruop() to new type fields
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -204,7 +204,7 @@
static Node *
integerop(char op, Node *lp, Node *rp)
{
- if (BTYPE(lp) != INT || BTYPE(rp) != INT)
+ if (!lp->type->integer || !rp->type->integer)
error("operator requires integer operands");
arithconv(&lp, &rp);
return simplify(op, lp->type, lp, rp);
@@ -213,24 +213,20 @@
static Node *
numericaluop(char op, Node *np)
{
- switch (BTYPE(np)) {
- case INT:
- np = promote(np);
- case FLOAT:
- if (op == ONEG && np->op == ONEG)
- return np->left;
- if (op == OADD)
- return np;
- return simplify(op, np->type, np, NULL);
- default:
+ if (!np->type->arith)
error("unary operator requires numerical operand");
- }
+ np = promote(np);
+ if (op == ONEG && np->op == ONEG)
+ return np->left;
+ if (op == OADD)
+ return np;
+ return simplify(op, np->type, np, NULL);
}
static Node *
integeruop(char op, Node *np)
{
- if (BTYPE(np) != INT)
+ if (!np->type->integer)
error("unary operator requires integer operand");
np = promote(np);
if (op == OCPL && np->op == OCPL)