diff options
| author | gingerBill <bill@gingerbill.org> | 2025-01-01 17:26:15 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2025-01-01 17:26:15 +0000 |
| commit | 7b334d2bd9e881b450fb19e394d6d71840a62cf9 (patch) | |
| tree | de11b2d8cf8b41331e1bb8354292e0253272ea14 /src/check_expr.cpp | |
| parent | 1cf7a56ba700b8a20b4fe94459db416679501793 (diff) | |
Add `#branch_location`
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index cc9483187..fba9b8dad 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -8725,6 +8725,18 @@ gb_internal ExprKind check_basic_directive_expr(CheckerContext *c, Operand *o, A error(node, "#caller_expression may only be used as a default argument parameter"); o->type = t_string; o->mode = Addressing_Value; + } else if (name == "branch_location") { + if (!c->in_defer) { + error(node, "#branch_location may only be used within a 'defer' statement"); + } else if (c->curr_proc_decl) { + Entity *e = c->curr_proc_decl->entity; + if (e != nullptr) { + GB_ASSERT(e->kind == Entity_Procedure); + e->Procedure.uses_branch_location = true; + } + } + o->type = t_source_code_location; + o->mode = Addressing_Value; } else { if (name == "location") { init_core_source_code_location(c->checker); |