scc

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

commit 71e7972a9bb2ccabbc85d51b0082e0110fd07b42
parent 7526472b647e3559938eebc1c8aea98aa4f6ebed
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) {