Make static an attribute rather than a keyword prefix

This commit is contained in:
gingerBill
2019-02-23 22:17:27 +00:00
parent e551d2b25e
commit a9ab90bd24
9 changed files with 63 additions and 48 deletions
+8 -12
View File
@@ -2070,6 +2070,14 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
DECL_ATTRIBUTE_PROC(var_decl_attribute) {
ExactValue ev = check_decl_attribute_value(c, value);
if (name == "static") {
if (value != nullptr) {
error(elem, "'static' does not have any parameters");
}
ac->is_static = true;
return true;
}
if (c->curr_proc_decl != nullptr) {
error(elem, "Only a variable at file scope can have a '%.*s'", LIT(name));
return true;
@@ -2425,10 +2433,6 @@ 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");
@@ -2527,14 +2531,6 @@ 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;