shithub: scc

Download patch

ref: 79412493b4cd9c428b6335613d9f720b79b3faf8
parent: d5999e4023f08294856780febf26edcb4f1cb37f
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Jan 20 10:51:03 EST 2016

Fix eqtype()

Eqtype was not checking that both types had the same op, and it meant
that pointer and array could be compared equal.

--- a/cc1/types.c
+++ b/cc1/types.c
@@ -521,9 +521,11 @@
 		return 0;
 	if (tp1 == tp2)
 		return 1;
+	if (tp1->op != tp2->op)
+		return 0;
 	switch (tp1->op) {
 	case ARY:
-		if (tp1->op != tp2->op || tp1->n.elem != tp2->n.elem)
+		if (tp1->n.elem != tp2->n.elem)
 			return 0;
 	case PTR:
 		return eqtype(tp1->type, tp2->type);
@@ -530,7 +532,7 @@
 	case UNION:
 	case STRUCT:
 	case FTN:
-		if (tp1->op != tp2->op || tp1->n.elem != tp2->n.elem)
+		if (tp1->n.elem != tp2->n.elem)
 			return 0;
 		p1 = tp1->p.pars, p2 = tp2->p.pars;
 		for (n = tp1->n.elem; n > 0; --n) {