commit 79412493b4cd9c428b6335613d9f720b79b3faf8
parent d5999e4023f08294856780febf26edcb4f1cb37f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 20 Jan 2016 15:51:03 +0100
Fix eqtype()
Eqtype was not checking that both types had the same op, and it meant
that pointer and array could be compared equal.
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/cc1/types.c b/cc1/types.c
@@ -521,16 +521,18 @@ eqtype(Type *tp1, Type *tp2)
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);
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) {