commit eb9387c7d79bb73b5481decf9aa69a00707fa26b
parent faeb157307bc3ff25fa560b5c0a2c62494aa3d55
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 20 May 2016 15:29:27 +0200
[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.
Diffstat:
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/cc1/types.c b/cc1/types.c
@@ -312,18 +312,13 @@ eqtype(Type *tp1, Type *tp2)
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 @@ eqtype(Type *tp1, Type *tp2)
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;