Skip to content

Commit da1e66e

Browse files
committed
Use RBIMPL_WARNING_{PUSH,IGNORED,POP} to ignore warnings in C API specs
* We could define ruby/spec-specific macros for this but it's easier to just reuse what's in ruby headers.
1 parent 4f6bd61 commit da1e66e

File tree

4 files changed

+13
-54
lines changed

4 files changed

+13
-54
lines changed

optional/capi/ext/array_spec.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,8 @@ static VALUE copy_ary(RB_BLOCK_CALL_FUNC_ARGLIST(el, new_ary)) {
197197
}
198198

199199
// Suppress deprecations warnings for rb_iterate(), we want to test it while it exists
200-
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
201-
# pragma GCC diagnostic push
202-
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
203-
#elif defined(__clang__) && defined(__has_warning)
204-
# if __has_warning("-Wdeprecated-declarations")
205-
# pragma clang diagnostic push
206-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
207-
# endif
208-
#endif
200+
RBIMPL_WARNING_PUSH()
201+
RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations)
209202

210203
static VALUE array_spec_rb_iterate(VALUE self, VALUE ary) {
211204
VALUE new_ary = rb_ary_new();
@@ -262,13 +255,7 @@ static VALUE array_spec_rb_block_call_then_yield(VALUE self, VALUE obj) {
262255
return Qnil;
263256
}
264257

265-
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
266-
# pragma GCC diagnostic pop
267-
#elif defined(__clang__) && defined(__has_warning)
268-
# if __has_warning("-Wdeprecated-declarations")
269-
# pragma clang diagnostic pop
270-
# endif
271-
#endif
258+
RBIMPL_WARNING_POP()
272259

273260
static VALUE array_spec_rb_mem_clear(VALUE self, VALUE obj) {
274261
VALUE ary[1];

optional/capi/ext/object_spec.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,28 +154,14 @@ static VALUE object_specs_rb_obj_method(VALUE self, VALUE obj, VALUE method) {
154154
return rb_obj_method(obj, method);
155155
}
156156

157-
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
158-
# pragma GCC diagnostic push
159-
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
160-
#elif defined(__clang__) && defined(__has_warning)
161-
# if __has_warning("-Wdeprecated-declarations")
162-
# pragma clang diagnostic push
163-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
164-
# endif
165-
#endif
166-
167157
#ifndef RUBY_VERSION_IS_3_2
158+
// Suppress deprecations warnings for rb_obj_taint(), we want to test it while it exists
159+
RBIMPL_WARNING_PUSH()
160+
RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations)
168161
static VALUE object_spec_rb_obj_taint(VALUE self, VALUE obj) {
169162
return rb_obj_taint(obj);
170163
}
171-
#endif
172-
173-
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
174-
# pragma GCC diagnostic pop
175-
#elif defined(__clang__) && defined(__has_warning)
176-
# if __has_warning("-Wdeprecated-declarations")
177-
# pragma clang diagnostic pop
178-
# endif
164+
RBIMPL_WARNING_POP()
179165
#endif
180166

181167
static VALUE so_require(VALUE self) {

optional/capi/ext/string_spec.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -254,32 +254,20 @@ VALUE string_spec_rb_str_new5(VALUE self, VALUE str, VALUE ptr, VALUE len) {
254254
return rb_str_new5(str, RSTRING_PTR(ptr), FIX2INT(len));
255255
}
256256

257-
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
258-
# pragma GCC diagnostic push
259-
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
260-
#elif defined(__clang__) && defined(__has_warning)
261-
# if __has_warning("-Wdeprecated-declarations")
262-
# pragma clang diagnostic push
263-
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
264-
# endif
265-
#endif
266-
267257
#ifndef RUBY_VERSION_IS_3_2
258+
// Suppress deprecations warnings for rb_tainted_str_new(), we want to test it while it exists
259+
RBIMPL_WARNING_PUSH()
260+
RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations)
261+
268262
VALUE string_spec_rb_tainted_str_new(VALUE self, VALUE str, VALUE len) {
269263
return rb_tainted_str_new(RSTRING_PTR(str), FIX2INT(len));
270264
}
271265

272266
VALUE string_spec_rb_tainted_str_new2(VALUE self, VALUE str) {
273267
return rb_tainted_str_new2(RSTRING_PTR(str));
274268
}
275-
#endif
276269

277-
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
278-
# pragma GCC diagnostic pop
279-
#elif defined(__clang__) && defined(__has_warning)
280-
# if __has_warning("-Wdeprecated-declarations")
281-
# pragma clang diagnostic pop
282-
# endif
270+
RBIMPL_WARNING_POP()
283271
#endif
284272

285273
VALUE string_spec_rb_str_plus(VALUE self, VALUE str1, VALUE str2) {

optional/capi/ext/thread_spec.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ static VALUE thread_spec_rb_thread_alone(VALUE self) {
2626
return rb_thread_alone() ? Qtrue : Qfalse;
2727
}
2828

29-
#if defined(__GNUC__)
30-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
31-
#endif
29+
RBIMPL_WARNING_IGNORED(-Wdeprecated-declarations)
3230

3331
/* This is unblocked by unblock_func(). */
3432
static void* blocking_gvl_func(void* data) {

0 commit comments

Comments
 (0)