commit e023b70a083338808f7e1e8e015df581c3a72823
parent 97f8f317d80776d196430997bea038e80709a206
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 7 Jan 2016 21:22:52 +0100
Convert pcompare() to use new fields of type
Diffstat:
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/cc1/expr.c b/cc1/expr.c
@@ -336,18 +336,21 @@ arithmetic(char op, Node *lp, Node *rp)
static Node *
pcompare(char op, Node *lp, Node *rp)
{
- switch (BTYPE(rp)) {
- case INT:
- if (cmpnode(rp, 0))
- rp = convert(rp, pvoidtype, 1);
- break;
- case PTR:
- if (lp->type != rp->type)
- warn("comparision between different pointer types");
- break;
- default:
- errorp("incompatibles type in comparision");
+ Node *np;
+ int err = 0;
+
+ if (rp->type->integer) {
+ if (!cmpnode(rp, 0))
+ err = 1;
+ rp = convert(rp, pvoidtype, 1);
+ } else if (rp->type->op == PTR) {
+ if (!eqtype(lp->type, rp->type))
+ err = 1;
+ } else {
+ err = 1;
}
+ if (err)
+ errorp("incompatibles type in comparision");
return simplify(op, inttype, lp, rp);
}