scc

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

commit 86ecad940ba36eef7bbe3c76cc2d76a7f012763a
parent eb8c10b2b2d7bfe987a2b00039ec4023bb54d1e6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 29 Jun 2012 21:57:02 +0200

Fixed bugs in declarator

The break in switch didn't break the for, so it was necessary a goto, and
the loop over the elements of the qlf array were pushed in incorrect
order (it was a stack and not a queue).

Diffstat:
Mdecl.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/decl.c b/decl.c @@ -98,7 +98,8 @@ signed_and_unsigned: static void declarator(void) { - unsigned char qlf[NR_DECLARATORS], *bp, *lim; + unsigned char qlf[NR_DECLARATORS]; + register unsigned char *bp, *lim; lim = &qlf[NR_DECLARATORS]; for (bp = qlf; yytoken == '*' && bp != lim; ++bp) { @@ -108,17 +109,19 @@ static void declarator(void) switch (yytoken) { case CONST: case VOLATILE: case RESTRICT: *bp++ = yytoken; - default: break; + default: + goto next_pointer; } } + next_pointer: ; } if (bp == lim) error("Too much type declarators"); dirdcl(); - while (bp-- != qlf) + for (lim = bp - 1, bp = qlf; bp < lim; ++bp) pushtype(*bp); }