scc

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

commit 660288e9ac9bb504280b5051a3e1d83bce617765
parent 50b60a65075cc74836becee050eb87f11642da75
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 17 Jul 2015 22:55:00 +0200

Add #endif clauses

I forgot it in the rewriting ^^!!!!.

Diffstat:
Mcc1/cc1.h | 1+
Mcc1/cpp.c | 10++++++++++
Mcc1/symbol.c | 1+
3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -202,6 +202,7 @@ enum tokens { IFDEF, IFNDEF, UNDEF, + ENDIF, EOFTOK }; diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -477,6 +477,15 @@ ifndef(void) } static void +endif(void) +{ + if (cppctx == 0) + error("#endif without #if"); + if (!ifstatus[--cppctx]) + --cppoff; +} + +static void elseclause(void) { if (cppctx == 0) @@ -513,6 +522,7 @@ cpp(void) {IFDEF, ifdef}, {IFNDEF, ifndef}, {ELSE, elseclause}, + {ENDIF, endif}, {UNDEF, undef}, {PRAGMA, pragma}, {ERROR, usererr}, diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -235,6 +235,7 @@ ikeywords(void) {"ifdef", IFDEF, IFDEF}, {"else", ELSE, ELSE}, {"ifndef", IFNDEF, IFNDEF}, + {"endif", ENDIF, ENDIF}, {"undef", UNDEF, UNDEF}, {"pragma", PRAGMA, PRAGMA}, {"error", ERROR, ERROR}