scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 9b1eafb87ca51b32030a2a53bed3f2170bf2f936
parent 7a2a1f936d8ca77484fa4ddb3b1244ecd350a8b5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 13 Aug 2015 16:14:55 +0200

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.

Diffstat:
cc1/types.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/cc1/types.c b/cc1/types.c @@ -337,15 +337,17 @@ eqtype(Type *tp1, Type *tp2) 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++))