aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorgrischka <grischka>2016-05-05 20:04:00 +0200
committergrischka <grischka>2016-05-05 20:04:00 +0200
commitd48662d49650099e5ab9e1fe218311a18c2ff73a (patch)
tree4af92eb69304fdef3e48c6ddb1a8972df80f0855 /tccgen.c
parentfe845cf53da206bb28f6b49a0878b0118b4f242b (diff)
downloadtinycc-d48662d49650099e5ab9e1fe218311a18c2ff73a.tar.gz
tinycc-d48662d49650099e5ab9e1fe218311a18c2ff73a.tar.bz2
tccgen: scopes levels for local symbols (update 1)
Catch top level redeclarations too. Also fix mistakes in tcctest.c and the tcc sources (win32) showing up now.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tccgen.c b/tccgen.c
index 042fb92..6954d3a 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -239,11 +239,10 @@ ST_FUNC Sym *sym_push(int v, CType *type, int r, int c)
ps = &ts->sym_identifier;
s->prev_tok = *ps;
*ps = s;
- if (local_scope) {
- s->scope = local_scope;
- if (s->prev_tok && s->prev_tok->scope == s->scope)
- tcc_error("redeclaration of '%s'", get_tok_str(v & ~SYM_STRUCT, NULL));
- }
+ s->scope = local_scope;
+ if (s->prev_tok && s->prev_tok->scope == s->scope)
+ tcc_error("redeclaration of '%s'",
+ get_tok_str(v & ~SYM_STRUCT, NULL));
}
return s;
}
@@ -2929,6 +2928,8 @@ static void struct_decl(CType *type, AttributeDef *ad, int u)
expect("struct/union/enum name");
s = struct_find(v);
if (s && s->type.t == a) {
+ if (0 == local_scope)
+ goto do_decl; /* compatibility with past behavior */
if (tok != '{' && tok != ';')
goto do_decl; /* variable declaration: 'struct s x;' */
if (s->scope == local_scope && (s->c == -1 || tok != '{'))