From b641b7e640b90292e8091348ca05def0a16904a8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 25 Dec 2023 14:08:21 +0900 Subject: [PATCH] Move non-portable pragmas to rubyspec.h In the extension libraries in spec/ruby/optional/capi, do not care about deprecated declarations. --- spec/ruby/optional/capi/ext/array_spec.c | 6 ------ spec/ruby/optional/capi/ext/encoding_spec.c | 3 --- spec/ruby/optional/capi/ext/object_spec.c | 4 ---- spec/ruby/optional/capi/ext/rubyspec.h | 23 +++++++++++++++++++++ spec/ruby/optional/capi/ext/string_spec.c | 6 ------ spec/ruby/optional/capi/ext/thread_spec.c | 2 -- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/spec/ruby/optional/capi/ext/array_spec.c b/spec/ruby/optional/capi/ext/array_spec.c index 8d5005c891..2347798bb4 100644 --- a/spec/ruby/optional/capi/ext/array_spec.c +++ b/spec/ruby/optional/capi/ext/array_spec.c @@ -196,10 +196,6 @@ static VALUE copy_ary(RB_BLOCK_CALL_FUNC_ARGLIST(el, new_ary)) { return rb_ary_push(new_ary, el); } -// Suppress deprecations warnings for rb_iterate(), we want to test it while it exists -RBIMPL_WARNING_PUSH() -RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations) - static VALUE array_spec_rb_iterate(VALUE self, VALUE ary) { VALUE new_ary = rb_ary_new(); @@ -255,8 +251,6 @@ static VALUE array_spec_rb_block_call_then_yield(VALUE self, VALUE obj) { return Qnil; } -RBIMPL_WARNING_POP() - static VALUE array_spec_rb_mem_clear(VALUE self, VALUE obj) { VALUE ary[1]; ary[0] = obj; diff --git a/spec/ruby/optional/capi/ext/encoding_spec.c b/spec/ruby/optional/capi/ext/encoding_spec.c index 4d2ff52ef3..3343848b54 100644 --- a/spec/ruby/optional/capi/ext/encoding_spec.c +++ b/spec/ruby/optional/capi/ext/encoding_spec.c @@ -271,15 +271,12 @@ static VALUE encoding_spec_rb_enc_str_asciionly_p(VALUE self, VALUE str) { } } -RBIMPL_WARNING_PUSH() -RBIMPL_WARNING_IGNORED(-Wformat-security) static VALUE encoding_spec_rb_enc_raise(VALUE self, VALUE encoding, VALUE exception_class, VALUE format) { rb_encoding *e = rb_to_encoding(encoding); const char *f = RSTRING_PTR(format); rb_enc_raise(e, exception_class, "%s", f); } -RBIMPL_WARNING_POP() static VALUE encoding_spec_rb_uv_to_utf8(VALUE self, VALUE buf, VALUE num) { int len = rb_uv_to_utf8(RSTRING_PTR(buf), NUM2INT(num)); diff --git a/spec/ruby/optional/capi/ext/object_spec.c b/spec/ruby/optional/capi/ext/object_spec.c index 4c19ec12c7..7023c29bdb 100644 --- a/spec/ruby/optional/capi/ext/object_spec.c +++ b/spec/ruby/optional/capi/ext/object_spec.c @@ -155,13 +155,9 @@ static VALUE object_specs_rb_obj_method(VALUE self, VALUE obj, VALUE method) { } #ifndef RUBY_VERSION_IS_3_2 -// Suppress deprecations warnings for rb_obj_taint(), we want to test it while it exists -RBIMPL_WARNING_PUSH() -RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations) static VALUE object_spec_rb_obj_taint(VALUE self, VALUE obj) { return rb_obj_taint(obj); } -RBIMPL_WARNING_POP() #endif static VALUE so_require(VALUE self) { diff --git a/spec/ruby/optional/capi/ext/rubyspec.h b/spec/ruby/optional/capi/ext/rubyspec.h index 80deca24c6..09135774af 100644 --- a/spec/ruby/optional/capi/ext/rubyspec.h +++ b/spec/ruby/optional/capi/ext/rubyspec.h @@ -11,6 +11,29 @@ # include #endif +/* copied from ext/-test-/cxxanyargs/cxxanyargs.cpp */ +#if 0 /* Ignore deprecation warnings */ + +#elif defined(_MSC_VER) +#pragma warning(disable : 4996) + +#elif defined(__INTEL_COMPILER) +#pragma warning(disable : 1786) + +#elif defined(__clang__) +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +#elif defined(__SUNPRO_CC) +#pragma error_messages (off,symdeprecated) + +#else +// :FIXME: improve here for your compiler. + +#endif + #ifndef RUBY_VERSION_MAJOR #define RUBY_VERSION_MAJOR RUBY_API_VERSION_MAJOR #define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR diff --git a/spec/ruby/optional/capi/ext/string_spec.c b/spec/ruby/optional/capi/ext/string_spec.c index 702620b9da..2bd789fb72 100644 --- a/spec/ruby/optional/capi/ext/string_spec.c +++ b/spec/ruby/optional/capi/ext/string_spec.c @@ -255,10 +255,6 @@ VALUE string_spec_rb_str_new5(VALUE self, VALUE str, VALUE ptr, VALUE len) { } #ifndef RUBY_VERSION_IS_3_2 -// Suppress deprecations warnings for rb_tainted_str_new(), we want to test it while it exists -RBIMPL_WARNING_PUSH() -RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations) - VALUE string_spec_rb_tainted_str_new(VALUE self, VALUE str, VALUE len) { return rb_tainted_str_new(RSTRING_PTR(str), FIX2INT(len)); } @@ -266,8 +262,6 @@ VALUE string_spec_rb_tainted_str_new(VALUE self, VALUE str, VALUE len) { VALUE string_spec_rb_tainted_str_new2(VALUE self, VALUE str) { return rb_tainted_str_new2(RSTRING_PTR(str)); } - -RBIMPL_WARNING_POP() #endif VALUE string_spec_rb_str_plus(VALUE self, VALUE str1, VALUE str2) { diff --git a/spec/ruby/optional/capi/ext/thread_spec.c b/spec/ruby/optional/capi/ext/thread_spec.c index 14bd207954..7d08d45098 100644 --- a/spec/ruby/optional/capi/ext/thread_spec.c +++ b/spec/ruby/optional/capi/ext/thread_spec.c @@ -26,8 +26,6 @@ static VALUE thread_spec_rb_thread_alone(VALUE self) { return rb_thread_alone() ? Qtrue : Qfalse; } -RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations) - /* This is unblocked by unblock_func(). */ static void* blocking_gvl_func(void* data) { int rfd = *(int *)data;