Merge pull request #7432 from kalsprite/asm_immediate_constant

Reject a non-constant argument to an  template's  immediate
This commit is contained in:
gingerBill
2026-08-25 16:20:38 +01:00
committed by GitHub
2 changed files with 14 additions and 2 deletions

4
.gitignore vendored
View File

@@ -277,6 +277,8 @@ odin
*.bin
demo.bin
libLLVM*.so*
*.a
*.o
# core:rexcode commits its generated encode/decode tables: each arch's tablegen
# emits human-readable Odin, serialized to tables/*.bin, which the library
@@ -321,5 +323,3 @@ build/
cmake-build*/
CMakeLists.txt
sandbox/
vendor/box3d/lib/box3d_wasm.o

View File

@@ -7008,6 +7008,18 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
}
}
// an `asm` template's `$` parameter is encoded as an immediate, so only a constant can reach it
if (e && e->kind == Entity_Variable && (e->flags & EntityFlag_PolyConst)) {
if (o->mode != Addressing_Constant) {
if (show_error) {
gbString str = expr_to_string(o->expr);
error(o->expr, "Expected a constant value for the '$' immediate '%.*s', got %s", LIT(e->token.string), str);
gb_string_free(str);
}
err = CallArgumentError_NoneConstantParameter;
}
}
if (e && e->kind == Entity_Constant && is_type_proc(e->type)) {
bool ok = false;
if (o->mode == Addressing_Constant) {