aboutsummaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2019-11-08 15:13:24 +0900
committerKoichi Sasada <ko1@atdot.net>2019-11-08 15:29:02 +0900
commit2eb02dfd3b650b54d6f3f5a63541e8165c997edd (patch)
treec9a296c37c7b41144a1d2fa10959aef75059e58e /tool
parent0ad0a8ff580a298dedc73c6679dd74d98c845ba9 (diff)
downloadruby-2eb02dfd3b650b54d6f3f5a63541e8165c997edd.tar.gz
Stop compiling if type mismatch was found.
If there is a type mismatch between expected builtin function type and actual function type, C compiler shows warning. For example, `__builtin_func(1, 2)` expects `func(rb_ec_t*, VALUE self, VALUE p1, VALUE p2)` function definition. However, it is easy to overlook "warning" messages. So this patch changes to stop compiling as an error if there is a mismatch.
Diffstat (limited to 'tool')
-rw-r--r--tool/mk_builtin_loader.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb
index 91a66b16b4..dafab79fd0 100644
--- a/tool/mk_builtin_loader.rb
+++ b/tool/mk_builtin_loader.rb
@@ -56,9 +56,15 @@ def mk_builtin_header file
f.puts
f.puts " // arity_check"
+ f.puts "COMPILER_WARNING_PUSH"
+ f.puts "#if GCC_VERSION_SINCE(5, 1, 0) || __clang__"
+ f.puts "COMPILER_WARNING_ERROR(-Wincompatible-pointer-types)"
+ f.puts "#endif"
bs.each{|func, argc|
f.puts " if (0) rb_builtin_function_check_arity#{argc}(#{func});"
}
+ f.puts "COMPILER_WARNING_POP"
+
path = File.expand_path(file)
f.puts