shithub: scc

Download patch

ref: 86ecad940ba36eef7bbe3c76cc2d76a7f012763a
parent: eb8c10b2b2d7bfe987a2b00039ec4023bb54d1e6
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Jun 29 17:57:02 EDT 2012

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

--- a/decl.c
+++ b/decl.c
@@ -98,7 +98,8 @@
 
 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,10 +109,12 @@
 			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");
@@ -118,7 +121,7 @@
 
 	dirdcl();
 
-	while (bp-- != qlf)
+	for (lim = bp - 1, bp = qlf; bp < lim; ++bp)
 		pushtype(*bp);
 }
 
--