shithub: scc

Download patch

ref: 7bc95eeda82f12145e9a7c835414ed3a58966c5a
parent: 941a776c59a79b6d64d07d09b38f3e9b00feeee3
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Aug 15 14:40:40 EDT 2012

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'.

--- a/decl.c
+++ b/decl.c
@@ -102,13 +102,14 @@
 	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;