From 1b1ea101bc1afd850080f6a53bf7321b3f9f2acd Mon Sep 17 00:00:00 2001 From: Chris Seaton Date: Mon, 20 Jan 2020 20:03:06 +0000 Subject: [PATCH 1/2] Fix rb_warn and rb_warning macros These can't have a ; at the end of them - think of the case: if (...) rb_warn(...); else ... This won't work with the ;; you'll get before the else. --- lib/cext/include/truffleruby/truffleruby.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cext/include/truffleruby/truffleruby.h b/lib/cext/include/truffleruby/truffleruby.h index b6ae2eba46d7..a8152f18da46 100644 --- a/lib/cext/include/truffleruby/truffleruby.h +++ b/lib/cext/include/truffleruby/truffleruby.h @@ -82,13 +82,13 @@ typedef void *(*gvl_call)(void *); if (polyglot_as_boolean(polyglot_invoke(RUBY_CEXT, "warn?"))) { \ RUBY_INVOKE(rb_mKernel, "warn", rb_sprintf(FORMAT, ##__VA_ARGS__)); \ } \ -} while (0); +} while (0) #define rb_warning(FORMAT, ...) do { \ if (polyglot_as_boolean(polyglot_invoke(RUBY_CEXT, "warning?"))) { \ RUBY_INVOKE(rb_mKernel, "warn", rb_sprintf(FORMAT, ##__VA_ARGS__)); \ } \ -} while (0); +} while (0) #define rb_tr_scan_args_1(ARGC, ARGV, FORMAT, V1) rb_tr_scan_args(ARGC, ARGV, FORMAT, V1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) #define rb_tr_scan_args_2(ARGC, ARGV, FORMAT, V1, V2) rb_tr_scan_args(ARGC, ARGV, FORMAT, V1, V2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) From 048aacbb1733d1de496dfdc1fa56065f63437d3f Mon Sep 17 00:00:00 2001 From: Chris Seaton Date: Tue, 21 Jan 2020 14:55:03 +0000 Subject: [PATCH 2/2] Change log entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8a289dd5850..4ba69eca5d2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ New features: Bug fixes: * Fixed `Exception#dup` to copy exception backtrace string array. +* Fixed `rb_warn` and `rb_warning` when used as statements (#1886, @chrisseaton). Compatibility: