shithub: scc

Download patch

ref: 03f9a752d53b3b3f15344bd610b292393b5e13f2
parent: e1ea759cef4ef3331b24d5fb90f28438a1df3070
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Jun 29 21:47:23 EDT 2012

Fixed bug in functions declarations

After a function we don't have to expect a ;, because it will mark end of
declarations and expressions, and not a function body. It is necessary add a
return value for the function in order to can detect this condition, and in
this case avoid the expecting of ;.

--- a/decl.c
+++ b/decl.c
@@ -125,7 +125,7 @@
 		pushtype(*bp);
 }
 
-static void listdcl(register struct ctype *cp)
+static unsigned char listdcl(register struct ctype *cp)
 {
 	register  struct type *tp;
 
@@ -138,9 +138,11 @@
 				      yytext);
 		} else if (tp->op == FTN && yytoken == '{') {
 			compound();
-			return;
+			return 0;
 		}
 	} while (accept(','));
+
+	return 1;
 }
 
 unsigned char decl(void)
@@ -158,10 +160,9 @@
 	if (yytoken == ';') {
 		warning_error(user_opt.useless_typename,
 			      "useless type name in empty declaration");
-	} else {
-		listdcl(&ctype);
+	} else if (listdcl(&ctype)) { /* in case of not being a function */
+		expect(';');
 	}
-	expect(';');
 
 	return 1;
 }
--