zig
zig copied to clipboard
Sema: catch invalid asm input operands
$ zig-out/bin/zig test test/cases/compile_errors/non_sized_asm_input_operand.zig
test/cases/compile_errors/non_sized_asm_input_operand.zig:4:23: error: input operand of type 'type' is not sized
: [_] "{al}" (u8),
^~
test/cases/compile_errors/non_sized_asm_input_operand.zig:12:22: error: input operand of type 'type' is not sized
[_] "{x}" (void),
^~~~
test/cases/compile_errors/non_sized_asm_input_operand.zig:19:22: error: input operand of type 'type' is not sized
: [_] "{x}" (enum {}),
^~~~~~~
I don't know if disallowing non-sized types is the best solution because for example RISC-V has a zero register that is hardwired to zero so : [x0] "{x0}" (@as(u0, 0)),
in a way could be valid but u0
is non-sized so it won't work.
At the same time though you can argue that anything that isn't sized can't actually be in a register.
Fixes #7843 (wasn't an issue with just stage1 btw, stage2 too segfaults without this patch)