ref: e023b70a083338808f7e1e8e015df581c3a72823
parent: 97f8f317d80776d196430997bea038e80709a206
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jan 7 16:22:52 EST 2016
Convert pcompare() to use new fields of type
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -336,18 +336,21 @@
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);
}