static variable declarations (Experimental)

This commit is contained in:
gingerBill
2018-12-28 13:31:06 +00:00
parent 775f1e2c95
commit a240a3d146
8 changed files with 104 additions and 5 deletions
+12
View File
@@ -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;