From b0f01202677da255f2004b4d6de43088202a0f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Thu, 9 Sep 2021 21:44:06 +0900 Subject: [PATCH] spec/ruby/optional/capi/ext: support ruby < 3 RBIMPL_WARNING_PUSH is a 3.0 feature. Rubyspec OTOH has to support 2.x. --- spec/ruby/optional/capi/ext/object_spec.c | 22 +++++++++++++++------- spec/ruby/optional/capi/ext/string_spec.c | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/spec/ruby/optional/capi/ext/object_spec.c b/spec/ruby/optional/capi/ext/object_spec.c index eae2446976..05ce44508d 100644 --- a/spec/ruby/optional/capi/ext/object_spec.c +++ b/spec/ruby/optional/capi/ext/object_spec.c @@ -151,19 +151,27 @@ static VALUE object_specs_rb_obj_method(VALUE self, VALUE obj, VALUE method) { return rb_obj_method(obj, method); } - -RBIMPL_WARNING_PUSH() -#if RBIMPL_HAS_WARNING("-Wdeprecated-declarations") || RBIMPL_COMPILER_SINCE(GCC, 4, 6, 0) -/* GCC 4.5 introduced __attribute__((__deprecated__)) */ -/* GCC 4.6 introduced #pragma GCC diagnostic push */ -RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations) +#if defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated-declarations") +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +# endif #endif static VALUE object_spec_rb_obj_taint(VALUE self, VALUE obj) { return rb_obj_taint(obj); } -RBIMPL_WARNING_POP() +#if defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic pop +#elif defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated-declarations") +# pragma clang diagnostic pop +# endif +#endif static VALUE so_require(VALUE self) { rb_require("fixtures/foo"); diff --git a/spec/ruby/optional/capi/ext/string_spec.c b/spec/ruby/optional/capi/ext/string_spec.c index 7977a2f6d8..11f0ffd856 100644 --- a/spec/ruby/optional/capi/ext/string_spec.c +++ b/spec/ruby/optional/capi/ext/string_spec.c @@ -251,11 +251,14 @@ VALUE string_spec_rb_str_new5(VALUE self, VALUE str, VALUE ptr, VALUE len) { return rb_str_new5(str, RSTRING_PTR(ptr), FIX2INT(len)); } -RBIMPL_WARNING_PUSH() -#if RBIMPL_HAS_WARNING("-Wdeprecated-declarations") || RBIMPL_COMPILER_SINCE(GCC, 4, 6, 0) -/* GCC 4.5 introduced __attribute__((__deprecated__)) */ -/* GCC 4.6 introduced #pragma GCC diagnostic push */ -RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations) +#if defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated-declarations") +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +# endif #endif VALUE string_spec_rb_tainted_str_new(VALUE self, VALUE str, VALUE len) { @@ -266,7 +269,13 @@ VALUE string_spec_rb_tainted_str_new2(VALUE self, VALUE str) { return rb_tainted_str_new2(RSTRING_PTR(str)); } -RBIMPL_WARNING_POP() +#if defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# pragma GCC diagnostic pop +#elif defined(__clang__) && defined(__has_warning) +# if __has_warning("-Wdeprecated-declarations") +# pragma clang diagnostic pop +# endif +#endif VALUE string_spec_rb_str_plus(VALUE self, VALUE str1, VALUE str2) { return rb_str_plus(str1, str2);