scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 1fd69c115bb5155d7dca44242d9c331d122786a4
parent f78f068b7f726cab481c4c95facda19f4efa8ba5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 10 Aug 2015 23:15:53 +0200

Fix eqtype() bug

Number of elements in functions can be negative
(the void case).

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

diff --git a/cc1/types.c b/cc1/types.c @@ -330,9 +330,11 @@ mktype(Type *tp, unsigned op, short nelem, Type *pars[]) bool eqtype(Type *tp1, Type *tp2) { - unsigned n; + int n; Type **p1, **p2; + if (!tp1 || !tp2) + return 0; if (tp1 == tp2) return 1; if (tp1->op != tp2->op || tp1->n.elem != tp2->n.elem) @@ -345,7 +347,7 @@ eqtype(Type *tp1, Type *tp2) case STRUCT: case FTN: p1 = tp1->pars, p2 = tp2->pars; - for (n = tp1->n.elem; n != 0; --n) { + for (n = tp1->n.elem; n > 0; --n) { if (!eqtype(*p1++, *p2++)) return 0; }