shithub: scc

Download patch

ref: 2fe852042893ad264f303ed805ae09be383f5dd7
parent: e023b70a083338808f7e1e8e015df581c3a72823
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jan 7 16:32:44 EST 2016

Convert compare() to use the new fileds in Type

--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -357,31 +357,24 @@
 static Node *
 compare(char op, Node *lp, Node *rp)
 {
+	Type *ltp, *rtp;
+
 	lp = decay(lp);
 	rp = decay(rp);
+	ltp = lp->type;
+	rtp = rtp->type;
 
-	switch (BTYPE(lp)) {
-	case INT:
-	case FLOAT:
-		switch (BTYPE(rp)) {
-		case INT:
-		case FLOAT:
-			arithconv(&lp, &rp);
-			break;
-		case PTR:
-			return pcompare(op, rp, lp);
-		default:
-			goto nocompat;
-		}
-		break;
-	case PTR:
-		return pcompare(op, lp, rp);
-	default:
-	nocompat:
+	if (ltp->op == PTR || rtp->op == PTR) {
+		return pcompare(op, rp, lp);
+	} else if (ltp->arith && rtp->arith) {
+		arithconv(&lp, &rp);
+		return simplify(op, inttype, lp, rp);
+	} else {
 		errorp("incompatibles type in comparision");
+		freetree(lp);
+		freetree(rp);
+		return constnode(zero);
 	}
-
-	return simplify(op, inttype, lp, rp);
 }
 
 int