Commit ddf824be
ddf824be6774Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
Emit an empty body for void instance_eval/exec trampoline stubs
The trampoline stub branch in emit_method emitted return 0; for a
void-returning method (configure/bump_by infer void since the inlined
instance_exec value is discarded). A value return in a void function
trips -Wreturn-type, which MinGW gcc keeps on regardless of -Wno-all; the
generated-C test compile uses -Werror, so it failed there as a hard
compile error (the test errored only on Windows). Emit { } for the
void case instead -- well-formed C on every toolchain.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- ddf824be6774
- Parent
- 8d644148ccbb
src/codegen.cmodifiedView file
@@ -366,11 +366,18 @@
366366
if (s->class_id >= 0 && !s->is_cmethod && s->name &&367367
comp_trampoline_kind(c, s->class_id, s->name, NULL)) {368368
emit_method_signature(c, s, b);369-
buf_puts(b, " {\n return ");370-
if (method_is_void(s)) buf_puts(b, "0");371-
else if (ty_is_object(s->ret)) buf_puts(b, "NULL");372-
else buf_puts(b, default_value(s->ret));373-
buf_puts(b, ";\n}\n");369+
if (method_is_void(s)) {370+
/* A `return <value>;` in a void function is a constraint violation that371+
MinGW gcc flags under -Werror (-Wno-all doesn't cover -Wreturn-type372+
there); emit an empty body instead. */373+
buf_puts(b, " {\n}\n");374+
}375+
else {376+
buf_puts(b, " {\n return ");377+
if (ty_is_object(s->ret)) buf_puts(b, "NULL");378+
else buf_puts(b, default_value(s->ret));379+
buf_puts(b, ";\n}\n");380+
}374381
return;375382
}376383
emit_method_signature(c, s, b);