scc

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

commit 7bc95eeda82f12145e9a7c835414ed3a58966c5a
parent 941a776c59a79b6d64d07d09b38f3e9b00feeee3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 15 Aug 2012 18:40:40 +0200

Fixed bug reading pointer modifiers

The code was reading only one character in each iteration of the loop, and
this was working in the case of indirection without modifiers (ex: int *v),
but was erroneus in the case of two indirection levels (ex: int *const
v). It is necessary one next() call for each '*' token and other call for
each 'const', 'volatile' or 'restrict'.

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

diff --git a/decl.c b/decl.c @@ -102,13 +102,14 @@ static void declarator(void) register unsigned char *bp, *lim; lim = &qlf[NR_DECLARATORS]; - for (bp = qlf; yytoken == '*' && bp != lim; next()) { + for (bp = qlf; yytoken == '*' && bp != lim; ) { + next(); *bp++ = PTR; while (bp != lim) { - next(); switch (yytoken) { case CONST: case VOLATILE: case RESTRICT: *bp++ = yytoken; + next(); break; default: goto continue_outer;