[hackers] [scc] Convert pcompare() to use new fields of type || Roberto E. Vargas Caballero
commit e023b70a083338808f7e1e8e015df581c3a72823
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Jan 7 21:22:52 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Jan 8 10:49:29 2016 +0100
Convert pcompare() to use new fields of type
diff --git a/cc1/expr.c b/cc1/expr.c
index 88a43c4..5251fd4 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -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);
}
Received on Fri Jan 08 2016 - 13:13:58 CET
This archive was generated by hypermail 2.3.0
: Fri Jan 08 2016 - 13:24:41 CET