diff options
| author | gingerBill <bill@gingerbill.org> | 2024-07-14 15:30:40 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-07-14 15:30:40 +0100 |
| commit | 556355ef054bc5139a24f8b5dbd210049e908c95 (patch) | |
| tree | b38b234cbd11a906592364699d0bd8b4bd4fa5ea /src/check_expr.cpp | |
| parent | 5de6016e7ff1d959c5deed3b878a75e5e078b5b2 (diff) | |
Disallow global use of target specific procedure calls
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 4edd34990..3b1f86114 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -7904,12 +7904,15 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c // NOTE: Due to restrictions in LLVM you can not inline calls with a superset of features. if (is_call_inlined) { - GB_ASSERT(c->curr_proc_decl); - GB_ASSERT(c->curr_proc_decl->entity); - GB_ASSERT(c->curr_proc_decl->entity->type->kind == Type_Proc); - String scope_features = c->curr_proc_decl->entity->type->Proc.enable_target_feature; - if (!check_target_feature_is_superset_of(scope_features, pt->Proc.enable_target_feature, &invalid)) { - error(call, "Inlined procedure enables target feature '%.*s', this requires the calling procedure to at least enable the same feature", LIT(invalid)); + if (c->curr_proc_decl == nullptr) { + error(call, "Inlined procedure which enables target feature '%.*s' cannot be used at the global/file scope", LIT(invalid)); + } else { + GB_ASSERT(c->curr_proc_decl->entity); + GB_ASSERT(c->curr_proc_decl->entity->type->kind == Type_Proc); + String scope_features = c->curr_proc_decl->entity->type->Proc.enable_target_feature; + if (!check_target_feature_is_superset_of(scope_features, pt->Proc.enable_target_feature, &invalid)) { + error(call, "Inlined procedure enables target feature '%.*s', this requires the calling procedure to at least enable the same feature", LIT(invalid)); + } } } } |