Commit 5aa0e6e4

5aa0e6e401f2Merged

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

Description

src: declare buf_* before the inline emit_indent that uses buf_puts

emit_indent (a static inline in codegen_internal.h) calls buf_puts, but the buf_* prototypes sat in the cross-part declaration block far below it. clang errors on the use-before-declaration (implicit function declaration); gcc only warned under -Wno-all, so CI (clang) went red while local gcc builds stayed green. Move the three buf_* declarations up next to the Buf typedef, before emit_indent.

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

Details

Commit
5aa0e6e401f2
Parent
105fe6e80741

src/codegen_internal.hmodifiedView file

@@ -22,6 +22,13 @@
2222
2323 typedef struct { char *p; size_t len, cap; } Buf;
2424
25+/* Buffer ops (defined in codegen_util.c). Declared here, before the
26+ inline emit_indent below uses buf_puts -- otherwise the inline body
27+ references an undeclared function (clang errors, gcc warns). */
28+void buf_putn(Buf *b, const char *s, size_t n);
29+void buf_puts(Buf *b, const char *s);
30+void buf_printf(Buf *b, const char *fmt, ...);
31+
2532 static inline void emit_indent(Buf *b, int n) { for (int i = 0; i < n; i++) buf_puts(b, " "); }
2633
2734 /* Statement prelude: some expressions (array/hash literals) lower to
@@ -275,9 +282,8 @@
275282
276283
277284 /* ---- cross-part function declarations (generated by the split) ---- */
278-void buf_putn(Buf *b, const char *s, size_t n);
279-void buf_puts(Buf *b, const char *s);
280-void buf_printf(Buf *b, const char *fmt, ...);
285+/* buf_putn / buf_puts / buf_printf are declared earlier (next to Buf),
286+ so the inline emit_indent can use buf_puts. */
281287 int re_engine_flags(int pf);
282288 int re_has_captures(const char *src);
283289 int re_lit_index(Compiler *c, int nid);