shithub: scc

Download patch

ref: e6a65a5026180565762dbbe8ec0300ba1ec4d86c
parent: 15c8ffc688a52d0596cbd9a27a1dd30aa51c0118
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri May 20 11:29:27 EDT 2016

[cc1] Fix eqtype() for functions

Eqtype() check if two types are equivalent, but it was wrong in the
case of functions, because it was not checking that the functions
returned the same type.

--- a/cc1/types.c
+++ b/cc1/types.c
@@ -312,18 +312,13 @@
 	TINT n;
 	Type **p1, **p2;
 
-	if (!tp1 || !tp2)
-		return 0;
 	if (tp1 == tp2)
 		return 1;
+	if (!tp1 || !tp2)
+		return 0;
 	if (tp1->op != tp2->op)
 		return 0;
 	switch (tp1->op) {
-	case ARY:
-		if (tp1->n.elem != tp2->n.elem)
-			return 0;
-	case PTR:
-		return eqtype(tp1->type, tp2->type);
 	case UNION:
 	case STRUCT:
 	case FTN:
@@ -334,7 +329,13 @@
 			if (!eqtype(*p1++, *p2++))
 				return 0;
 		}
-		return 1;
+		goto check_base;
+	case ARY:
+		if (tp1->n.elem != tp2->n.elem)
+			return 0;
+	case PTR:
+	check_base:
+		return eqtype(tp1->type, tp2->type);
 	case VOID:
 	case ENUM:
 		return 0;