spec/ruby/optional/capi/ext: support ruby < 3

RBIMPL_WARNING_PUSH is a 3.0 feature.  Rubyspec OTOH has to support 2.x.
This commit is contained in:
卜部昌平 2021-09-09 21:44:06 +09:00
Родитель b563b9c48f
Коммит b0f0120267
2 изменённых файлов: 30 добавлений и 13 удалений

Просмотреть файл

@ -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");

Просмотреть файл

@ -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);