Skip to content

Commit

Permalink
Move non-portable pragmas to rubyspec.h
Browse files Browse the repository at this point in the history
In the extension libraries in spec/ruby/optional/capi, do not care
about deprecated declarations.
  • Loading branch information
nobu committed Dec 25, 2023
1 parent 863ded4 commit b641b7e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
6 changes: 0 additions & 6 deletions spec/ruby/optional/capi/ext/array_spec.c
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions spec/ruby/optional/capi/ext/encoding_spec.c
Expand Up @@ -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));
Expand Down
4 changes: 0 additions & 4 deletions spec/ruby/optional/capi/ext/object_spec.c
Expand Up @@ -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) {
Expand Down
23 changes: 23 additions & 0 deletions spec/ruby/optional/capi/ext/rubyspec.h
Expand Up @@ -11,6 +11,29 @@
# include <version.h>
#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
Expand Down
6 changes: 0 additions & 6 deletions spec/ruby/optional/capi/ext/string_spec.c
Expand Up @@ -255,19 +255,13 @@ 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));
}

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) {
Expand Down
2 changes: 0 additions & 2 deletions spec/ruby/optional/capi/ext/thread_spec.c
Expand Up @@ -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;
Expand Down

0 comments on commit b641b7e

Please sign in to comment.