diff options
| author | gingerBill <bill@gingerbill.org> | 2024-06-20 15:32:30 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-06-20 15:32:30 +0100 |
| commit | dab3c832e00a3186bddc79585d9ba7ee10d39eaf (patch) | |
| tree | 92a9947ad6f4c26250e791c259ecc17fe622a4db /src/check_builtin.cpp | |
| parent | 94a8c38d86460710df485a11e639e978c8b922cd (diff) | |
Add `#warning(<string>)` builtin compile time procedure
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 47abd42cf..e85981911 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -1714,6 +1714,26 @@ gb_internal bool check_builtin_procedure_directive(CheckerContext *c, Operand *o operand->type = t_untyped_bool; operand->mode = Addressing_Constant; + } else if (name == "warning") { + ERROR_BLOCK(); + if (ce->args.count != 1) { + error(call, "'#warning' expects 1 argument, got %td", ce->args.count); + return false; + } + if (!is_type_string(operand->type) && operand->mode != Addressing_Constant) { + gbString str = expr_to_string(ce->args[0]); + error(call, "'%s' is not a constant string", str); + gb_string_free(str); + return false; + } + warning(call, "%.*s", LIT(operand->value.value_string)); + if (c->proc_name != "") { + gbString str = type_to_string(c->curr_proc_sig); + error_line("\tCalled within '%.*s' :: %s\n", LIT(c->proc_name), str); + gb_string_free(str); + } + operand->type = t_invalid; + operand->mode = Addressing_NoValue; } else if (name == "panic") { ERROR_BLOCK(); if (ce->args.count != 1) { |