Skip to content

Commit b8867bd

Browse files
committed
[GR-18163] Ensure all headers are warnings-free
PullRequest: truffleruby/3365
2 parents fdecea5 + d3e9dc2 commit b8867bd

File tree

13 files changed

+37
-8
lines changed

13 files changed

+37
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Compatibility:
3434
* Improve support of `:chomp` keyword argument in `IO` and `StringIO` methods (#2650, @andrykonchin).
3535
* Implement specializations for immutable ruby objects for ObjectSpace methods (@bjfish).
3636
* Use `$PAGER` for `--help` and `--help*`, similar to CRuby (#2542, @Strech).
37+
* Ensure all headers are warnings-free (#2662, @eregon).
3738

3839
Performance:
3940

lib/cext/ABI_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5
1+
6

lib/cext/include/ruby/internal/core/rarray.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ RARRAY_LENINT(VALUE ary)
161161
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
162162
RBIMPL_ATTR_ARTIFICIAL()
163163
static inline bool
164+
#ifdef TRUFFLERUBY
165+
RARRAY_TRANSIENT_P(RB_UNUSED_VAR(VALUE ary))
166+
#else
164167
RARRAY_TRANSIENT_P(VALUE ary)
168+
#endif
165169
{
166170
RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
167171

lib/cext/include/ruby/internal/rgengc.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,27 @@ rb_obj_wb_unprotect(VALUE x, RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(
171171
}
172172
#endif // TRUFFLERUBY
173173

174+
#ifdef TRUFFLERUBY
175+
static inline VALUE
176+
rb_obj_written(VALUE a, RB_UNUSED_VAR(VALUE oldv), RB_UNUSED_VAR(VALUE b), RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(int line))
177+
{
178+
return a;
179+
}
180+
#else
174181
static inline VALUE
175182
rb_obj_written(VALUE a, RB_UNUSED_VAR(VALUE oldv), VALUE b, RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(int line))
176183
{
177184
#if USE_RGENGC_LOGGING_WB_UNPROTECT
178185
RGENGC_LOGGING_OBJ_WRITTEN(a, oldv, b, filename, line);
179186
#endif
180187

181-
#ifndef TRUFFLERUBY
182188
if (!RB_SPECIAL_CONST_P(b)) {
183189
rb_gc_writebarrier(a, b);
184190
}
185-
#endif
186191

187192
return a;
188193
}
194+
#endif
189195

190196
static inline VALUE
191197
rb_obj_write(VALUE a, VALUE *slot, VALUE b, RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(int line))

lib/cext/include/ruby/internal/special_consts.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ RBIMPL_ATTR_CONST()
163163
RBIMPL_ATTR_CONSTEXPR(CXX11)
164164
RBIMPL_ATTR_ARTIFICIAL()
165165
static inline bool
166+
#ifdef TRUFFLERUBY
167+
RB_FLONUM_P(RB_UNUSED_VAR(VALUE obj))
168+
#else
166169
RB_FLONUM_P(VALUE obj)
170+
#endif
167171
{
168172
#if USE_FLONUM
169173
return (obj & RUBY_FLONUM_MASK) == RUBY_FLONUM_FLAG;

lib/cext/include/truffleruby/truffleruby.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,12 @@ ALWAYS_INLINE(static int rb_tr_scan_args_kw_int(int kw_flag, int argc, VALUE *ar
224224
static inline int rb_tr_scan_args_kw_int(int kw_flag, int argc, VALUE *argv, struct rb_tr_scan_args_parse_data parse_data, VALUE *v1, VALUE *v2, VALUE *v3, VALUE *v4, VALUE *v5, VALUE *v6, VALUE *v7, VALUE *v8, VALUE *v9, VALUE *v10) {
225225

226226
int keyword_given = 0;
227-
int last_hash_keyword = 0;
227+
// int last_hash_keyword = 0;
228228

229229
switch (kw_flag) {
230230
case RB_SCAN_ARGS_PASS_CALLED_KEYWORDS: break;
231231
case RB_SCAN_ARGS_KEYWORDS: keyword_given = 1; break;
232-
case RB_SCAN_ARGS_LAST_HASH_KEYWORDS: last_hash_keyword = 1; break;
232+
case RB_SCAN_ARGS_LAST_HASH_KEYWORDS: /* last_hash_keyword = 1; not used currently */ break;
233233
}
234234

235235
// Check we have enough arguments
@@ -398,7 +398,6 @@ static inline int rb_tr_scan_args_kw_int(int kw_flag, int argc, VALUE *argv, str
398398
ALWAYS_INLINE(static int rb_tr_scan_args_kw_non_const(int kw_flag, int argc, VALUE *argv, const char *format, VALUE *v1, VALUE *v2, VALUE *v3, VALUE *v4, VALUE *v5, VALUE *v6, VALUE *v7, VALUE *v8, VALUE *v9, VALUE *v10));
399399
static inline int rb_tr_scan_args_kw_non_const(int kw_flag, int argc, VALUE *argv, const char *format, VALUE *v1, VALUE *v2, VALUE *v3, VALUE *v4, VALUE *v5, VALUE *v6, VALUE *v7, VALUE *v8, VALUE *v9, VALUE *v10) {
400400

401-
const char *formatp = format;
402401
struct rb_tr_scan_args_parse_data parse_data = {0, 0, false, 0, false, false};
403402

404403
rb_tr_scan_args_kw_parse(format, &parse_data);

test/truffle/cexts/werror/bin/werror

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'werror/werror'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello!
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
require 'mkmf'
2+
# No -pedantic because polyglot-impl.h fails that, and well, it's too pedantic
3+
$warnflags << ' -W -Wall -Wextra -Werror'
4+
create_makefile('werror')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
#include <ruby.h>
3+
4+
void Init_werror() {
5+
printf("Hello!\n");
6+
}

0 commit comments

Comments
 (0)