scc

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

commit 25458d1f56c528c6838f840c289b0cd91301cd19
parent b589b5bea208bd5be1fa724f5f7a2af6b65b2cae
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date:   Sat, 23 Apr 2016 17:20:24 +0200

[cc2] Add a ONOP statement for every label

This nop statement helps to have some statement in the same position
where the label is set. We do not depend of being the last statement
or setting some variable for the next statement.

Diffstat:
Mcc2/parser.c | 28++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -569,20 +569,6 @@ flddecl(void) } static void -labeldcl(void) -{ - Node *np; - Symbol *sym; - - np = pop(); - sym = np->u.sym; - delnode(np); - nextline(); - stmtp->label = sym; - sym->u.nlabel = stmtp; -} - -static void addstmt(Node *np) { if (!curfun->u.nlabel) @@ -593,6 +579,20 @@ addstmt(Node *np) } static void +labeldcl(void) +{ + Node *np; + Symbol *sym; + + np = pop(); + np->op = ONOP; + sym = np->u.sym; + sym->kind = SLABEL; + np->label = sym; + addstmt(np); +} + +static void stmt(void) { Node *np;