diff options
| author | gingerBill <bill@gingerbill.org> | 2021-11-04 12:40:50 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-11-04 12:40:50 +0000 |
| commit | 6ded538546cca4f1e50a011a64932f7f3c784cc2 (patch) | |
| tree | 03ac73c9042cc45ab20da51a93de3f9bf6f8de0f /src/check_decl.cpp | |
| parent | 3fa7dabaa87e99386e469bd5e4badab23f89aaef (diff) | |
`@(linkage=<string>)` for procedures and variables; `@(require)` for procedures; `package runtime` linkage improvements; Subsequence improvements to `lb_run_remove_unused_function_pass`
Diffstat (limited to 'src/check_decl.cpp')
| -rw-r--r-- | src/check_decl.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 33e85edf7..134dbb35b 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -730,7 +730,6 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { if (ac.set_cold) { e->flags |= EntityFlag_Cold; } - e->Procedure.optimization_mode = cast(ProcedureOptimizationMode)ac.optimization_mode; @@ -760,6 +759,22 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { bool is_foreign = e->Procedure.is_foreign; bool is_export = e->Procedure.is_export; + + if (ac.linkage.len != 0) { + if (ac.linkage == "internal") { e->flags |= EntityFlag_CustomLinkage_Internal; } + else if (ac.linkage == "strong") { e->flags |= EntityFlag_CustomLinkage_Strong; } + else if (ac.linkage == "weak") { e->flags |= EntityFlag_CustomLinkage_Weak; } + else if (ac.linkage == "link_once") { e->flags |= EntityFlag_CustomLinkage_LinkOnce; } + + if (is_foreign && (e->flags & EntityFlag_CustomLinkage_Internal)) { + error(e->token, "A foreign procedure may not have an \"internal\" linkage"); + } + } + + if (ac.require_declaration) { + e->flags |= EntityFlag_Require; + } + if (e->pkg != nullptr && e->token.string == "main") { if (pt->param_count != 0 || @@ -943,6 +958,7 @@ void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast *type_expr, } if (ac.require_declaration) { + e->flags |= EntityFlag_Require; mpmc_enqueue(&ctx->info->required_global_variable_queue, e); } |