scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 5ccd563163fe28d3bc20407895a97af850641c37
parent ddde1e80aa4f226cba3a42840bac8388c460f4a7
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 11 Nov 2021 19:05:00 +0100

cc1: Fix namespace for enumerations

The namespace must be modified before any token operation
is performed, otherwise we pollute the wrong namespace and
we insert the enum constants in other namespaces.

Diffstat:
Msrc/cmd/cc/cc1/decl.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cmd/cc/cc1/decl.c b/src/cmd/cc/cc1/decl.c @@ -796,12 +796,12 @@ enumdcl(void) tagsym = newtag(); tp = tagsym->type; + namespace = NS_IDEN; if (!accept('{')) goto restore_name; if (tp->prop & TDEFINED) errorp("redefinition of enumeration '%s'", tagsym->name); deftype(tp); - namespace = NS_IDEN; /* TODO: check incorrect values in val */ for (nctes = val = 0; yytoken != '}'; ++nctes, ++val) {