ref: ab4370799d5d87f08dd876f2dd53eedf16a4e518
parent: f3a5df345c3a7056c4298d4d2fe5034f19303897
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Aug 25 07:48:26 EDT 2015
Fix namespace in struct/union declarations struct/union can be nested, so it is very important to preserve the previous namespace.
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -422,8 +422,10 @@
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 @@
error("too levels of nested structure or union definitions");
++nested;
- while (!accept('}'))
+ while (yytoken != '}') {
fieldlist(tp);
+ }
--nested;
-restore_name:
namespace = ns;
+ expect('}');
return tp;
}