commit 193dfc1ff97b3b06883d6e27a5fc46c08b4a4b0b
parent 8c6c81f5f752c9829fc14197577e94ce6a84a2a6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 20 Oct 2022 19:06:24 +0200
cc1: Restore namespace before accepting a brace
When we call expect() we read the next token and in the case of a
symbol it means that we create it in the wrong namespace if we
don't restore the correct namespace before.
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/cmd/cc/cc1/decl.c b/src/cmd/cc/cc1/decl.c
@@ -822,8 +822,10 @@ enumdcl(void)
tp = tagsym->type;
namespace = NS_IDEN;
- if (!accept('{'))
- goto restore_name;
+ if (!accept('{')) {
+ namespace = ns;
+ return tp;
+ }
if (tp->prop & TDEFINED)
errorp("redefinition of enumeration '%s'", tagsym->name);
deftype(tp);
@@ -858,10 +860,8 @@ enumdcl(void)
if (!accept(','))
break;
}
- expect('}');
-
-restore_name:
namespace = ns;
+ expect('}');
return tp;
}