shithub: scc

Download patch

ref: 9b1eafb87ca51b32030a2a53bed3f2170bf2f936
parent: 7a2a1f936d8ca77484fa4ddb3b1244ecd350a8b5
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Aug 13 12:14:55 EDT 2015

Fix type comparision

Field n.elem cannot be used until we know that it is a field used
in the type, so we have to check first the op of the type.
This problem was generating errors in pointer type comparision.

--- a/cc1/types.c
+++ b/cc1/types.c
@@ -337,15 +337,17 @@
 		return 0;
 	if (tp1 == tp2)
 		return 1;
-	if (tp1->op != tp2->op || tp1->n.elem != tp2->n.elem)
-		return 0;
 	switch (tp1->op) {
 	case ARY:
+		if (tp1->op != tp2->op || tp1->n.elem != tp2->n.elem)
+			return 0;
 	case PTR:
 		return eqtype(tp1->type, tp2->type);
 	case UNION:
 	case STRUCT:
 	case FTN:
+		if (tp1->op != tp2->op || tp1->n.elem != tp2->n.elem)
+			return 0;
 		p1 = tp1->pars, p2 = tp2->pars;
 		for (n = tp1->n.elem; n > 0; --n) {
 			if (!eqtype(*p1++, *p2++))