Skip to content

Commit 9e5bf1b

Browse files
committed
wasm2c warm.h: inline panic to avoid compile warning
I got the following warning when compiling zig-wasm2c: C:\git\zig\stage1\wasm.h(55) : warning C4715: 'WasmMut_toC': not all control paths return a value This is because the C compiler doesn't understand that the panic function from `panic.h` is noreturn. I addressed this copying the body of the panic function into the call-site directly which is just a printf and abort. Now the compiler knows the codepath aftewards is unreachable because abort has the propery function decorators to mark it noreturn.
1 parent 8aab222 commit 9e5bf1b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stage1/wasm.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ static const char *WasmMut_toC(enum WasmMut val_type) {
5050
switch (val_type) {
5151
case WasmMut_const: return "const ";
5252
case WasmMut_var: return "";
53-
default: panic("unsupported mut");
53+
default:
54+
fprintf(stderr, "unsupported mut\n");
55+
abort();
5456
}
5557
}
5658

0 commit comments

Comments
 (0)