scc

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

commit 12d32d40a8be1d7c133aa5d6ab0032efc1a42345
parent 677b6d0afb4a3ea2ab70355922549204fc2f4918
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 15 Dec 2016 07:19:34 +0100

[cc1] Fix #elif clauses

The implmentation of elif was evaluating the if part always, even
when due to the else part it was disabled, and it was generating
that the current state of the preprocessor was corrupted.

Diffstat:
Mcc1/cpp.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -657,8 +657,9 @@ elseclause(void) return; } - status = (ifstatus[cppctx-1] ^= 1); - cppoff += (status) ? -1 : 1; + status = ifstatus[cppctx-1]; + ifstatus[cppctx-1] = !status; + cppoff += (status) ? 1 : -1; } static void @@ -672,8 +673,10 @@ static void elif(void) { elseclause(); - --cppctx; - cppif(); + if (ifstatus[cppctx-1]) { + --cppctx; + cppif(); + } } static void