From 325db44028d817942861ca98d6ed06c320fb39ae Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 1 Jul 2024 19:59:46 +0200 Subject: Disallow static undefined variables --- src/analyzer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/analyzer.c b/src/analyzer.c index 68029fd..e7199ca 100644 --- a/src/analyzer.c +++ b/src/analyzer.c @@ -195,9 +195,13 @@ analyzedecl(struct azctx ctx, scope_t *scps, type_t *types, ast_t ast, { strview_t sv = toks.strs[ast.lexemes[i]]; - bool isstatic = ast.kinds[i] <= _AST_DECLS_END - && aux.buf[ast.kids[i].lhs].decl.isstatic; bool isconst = ast.kinds[i] == ASTCDECL; + bool isundef = aux.buf[ast.kids[i].lhs].decl.isundef; + bool isstatic = ast.kinds[i] <= _AST_DECLS_END + && aux.buf[ast.kids[i].lhs].decl.isstatic; + + if (isstatic && isundef) + err("analyzer: Static variables may not be undefined"); if (!isconst && !isstatic) { symval_t *sym = symtab_insert(&scps[ctx.si].map, sv, ctx.a); -- cgit v1.2.3