From a240a3d14660f6b33f839a3ebf142e20aac3e80a Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 28 Dec 2018 13:31:06 +0000 Subject: `static` variable declarations (Experimental) --- src/checker.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/checker.cpp') diff --git a/src/checker.cpp b/src/checker.cpp index 7f56770b9..c2318e499 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -2282,6 +2282,10 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) { e->flags |= EntityFlag_NotExported; } + if (vd->is_static) { + e->flags |= EntityFlag_Static; + } + if (vd->is_using) { vd->is_using = false; // NOTE(bill): This error will be only caught once error(name, "'using' is not allowed at the file scope"); @@ -2386,6 +2390,14 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) { e->flags |= EntityFlag_NotExported; } + if (vd->is_static) { + if (e->kind == Entity_Constant) { + e->flags |= EntityFlag_Static; + } else { + error(name, "'static' is not allowed on this constant value declaration"); + } + } + if (vd->is_using) { if (e->kind == Entity_TypeName && init->kind == Ast_EnumType) { d->is_using = true; -- cgit v1.2.3