scc

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

commit 184510ee208d5f05b4f472d9ce295ecff044861d
parent f1dec280f4eb0f7b7fd8ee90fc70b1cecebd0c47
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 10 Sep 2014 22:31:13 +0200

Check correctness of endf functions in cc2

These commit enforces the check that when the file finishs
then the code is not inside some function.

Diffstat:
Mcc2/parser.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -363,6 +363,8 @@ deflabel(char *token) static void endfunction(char *token) { + if (!curfun) + error(ESYNTAX); listp = NULL; genstack(curfun); genaddable(listexp); @@ -487,7 +489,8 @@ parse(void) found_eof: if (ferror(stdin)) error(EFERROR, strerror(errno)); - return; + if (!curfun) + return; syntax_error: error(ESYNTAX);