Commit 7751669a

7751669a7dadMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified

Description

Keep generated C clang -Werror-clean: range float arg + unused-value

clang's default -Werror set is broader than gcc's (which the build runs with -Wno-all), so two patterns failed only the clang test job:

  • (1..).include?(2.4) emitted sp_range_include(&r, 2.4) -- an implicit float-literal->mrb_int conversion (-Wliteral-conversion). Emit an explicit (mrb_int) cast for a float arg, matching gcc's truncation.

  • A discarded value-producing statement-expression (e.g. the ({ ...; v; }) for Fiber[:k] = v in statement position) trips -Wunused-value. The value is intentionally dropped and behaviour is gated by the output diff, so suppress -Wunused-value in the generated-C test build (TEST_WARN_SUPPRESS) rather than risk a codegen change that mistypes the same statement-expr in value position.

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
7751669a7dad
Parent
ab8238525325

MakefilemodifiedView file

@@ -253,6 +253,14 @@
253253 endif
254254 TEST_TARGETS := $(patsubst test/%.rb,build/test-results/%.ok,$(TESTS))
255255
256+# Warnings the generated-C -Werror check should not gate on. clang enables
257+# -Wunused-value by default (gcc only under -Wall, which the build disables),
258+# so a discarded value-producing statement-expression -- e.g. the
259+# `({ ...; v; })` emitted for `Fiber[:k] = v` in statement position -- fails
260+# CI under clang while gcc is silent. The value is intentionally discarded;
261+# behaviour is still gated by the output diff. Keep this list minimal.
262+TEST_WARN_SUPPRESS := -Wno-unused-value
263+
256264 # `make test` always runs fresh: it wipes the prior `.ok` stamps first,
257265 # then runs the suite. (The old incremental `test` + `retest` split is
258266 # gone — a stale `.ok` reading PASS was a recurring foot-gun.)
@@ -335,7 +343,7 @@
335343 if [ -f "$<.args" ]; then args=$$(cat "$<.args"); fi; \
336344 rm -f "[email protected]"; \
337345 $(SPINEL) "$<" -c --no-line-map -o "$$cfile" 2>/dev/null && \
338- $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib -c "$$cfile" -o "$$cfile.o" 2>/dev/null && \
346+ $(CC) $(CFLAGS) -Werror $(TEST_WARN_SUPPRESS) $(SEC_FLAGS) -Ilib -c "$$cfile" -o "$$cfile.o" 2>/dev/null && \
339347 $(CC) $(CFLAGS) "$$cfile.o" $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o "$$bin" 2>/dev/null; \
340348 if [ $$? -eq 0 ]; then \
341349 if [ -f "$<.expected" ]; then \
@@ -401,7 +409,7 @@
401409 bn=$$(basename "$$f" .rb); \
402410 if [ "$$tty" = 1 ]; then printf '\r\033[K [%d/%d] %s' "$$i" "$$total" "$$bn"; fi; \
403411 $(TIMEOUT10) $(SPINEL) "$$f" -c --no-line-map -o /tmp/_sp_b.c 2>/dev/null && \
404- $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib -c /tmp/_sp_b.c -o /tmp/_sp_b.c.o 2>/dev/null && \
412+ $(CC) $(CFLAGS) -Werror $(TEST_WARN_SUPPRESS) $(SEC_FLAGS) -Ilib -c /tmp/_sp_b.c -o /tmp/_sp_b.c.o 2>/dev/null && \
405413 $(CC) $(CFLAGS) /tmp/_sp_b.c.o $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_b_bin$(EXE) 2>/dev/null; \
406414 if [ $$? -eq 0 ]; then \
407415 $(TIMEOUT60) $(REF_RUBY) "$$f" >/tmp/_sp_b_exp 2>/dev/null; \