scc

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

commit ab4370799d5d87f08dd876f2dd53eedf16a4e518
parent f3a5df345c3a7056c4298d4d2fe5034f19303897
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 25 Aug 2015 11:48:26 +0200

Fix namespace in struct/union declarations

struct/union can be nested, so it is very important to preserve
the previous namespace.

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

diff --git a/cc1/decl.c b/cc1/decl.c @@ -422,8 +422,10 @@ structdcl(void) tp = sym->type; namespace = tp->ns; - if (!accept('{')) - goto restore_name; + if (!accept('{')) { + namespace = ns; + return tp; + } if (tp->defined) error("redefinition of struct/union '%s'", sym->name); @@ -434,12 +436,13 @@ structdcl(void) error("too levels of nested structure or union definitions"); ++nested; - while (!accept('}')) + while (yytoken != '}') { fieldlist(tp); + } --nested; -restore_name: namespace = ns; + expect('}'); return tp; }