From d226ce8decef356c7447efb6b6b325bc8fc53dba Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 27 Apr 2016 05:29:49 +0000 Subject: internal.h: ONLY_FOR_INTERNAL_USE * error.c (ruby_only_for_internal_use): raise fatal error when deprecated function only for internal use is called, not just a warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ error.c | 10 ++++++++++ internal.h | 2 ++ pack.c | 6 ++---- vm.c | 3 +-- vm_method.c | 4 +--- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index e13a2257b0..3ca07fbbee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Apr 27 14:29:47 2016 Nobuyoshi Nakada + + * error.c (ruby_only_for_internal_use): raise fatal error when + deprecated function only for internal use is called, not just a + warning. + Tue Apr 26 23:42:30 2016 NAKAMURA Usaku * tool/redmine-backporter.rb (rel): should not raise exceptions even if diff --git a/error.c b/error.c index 214d12df5d..5a0184fa48 100644 --- a/error.c +++ b/error.c @@ -124,16 +124,26 @@ rb_syntax_error_append(VALUE exc, VALUE file, int line, int column, void rb_compile_error_with_enc(const char *file, int line, void *enc, const char *fmt, ...) { + ONLY_FOR_INTERNAL_USE("rb_compile_error_with_enc()"); } void rb_compile_error(const char *file, int line, const char *fmt, ...) { + ONLY_FOR_INTERNAL_USE("rb_compile_error()"); } void rb_compile_error_append(const char *fmt, ...) { + ONLY_FOR_INTERNAL_USE("rb_compile_error_append()"); +} + +void +ruby_only_for_internal_use(const char *func) +{ + rb_print_backtrace(); + rb_fatal("%s is only for internal use and deprecated; do not use", func); } static VALUE diff --git a/internal.h b/internal.h index 9ca1fb388c..b51a75113d 100644 --- a/internal.h +++ b/internal.h @@ -865,6 +865,8 @@ VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method); rb_exc_raise(rb_name_err_new(mesg, recv, name)) #define rb_name_err_raise(mesg, recv, name) \ rb_name_err_raise_str(rb_fstring_cstr(mesg), (recv), (name)) +NORETURN(void ruby_only_for_internal_use(const char *)); +#define ONLY_FOR_INTERNAL_USE(func) ruby_only_for_internal_use(func) /* eval.c */ VALUE rb_refinement_module_get_refined_class(VALUE module); diff --git a/pack.c b/pack.c index 9b4aa6a93f..ea7bd16fe8 100644 --- a/pack.c +++ b/pack.c @@ -220,15 +220,13 @@ str_associated(VALUE str) void rb_str_associate(VALUE str, VALUE add) { - rb_warn("rb_str_associate() is only for internal use and deprecated; do not use"); - str_associate(str, add); + ONLY_FOR_INTERNAL_USE("rb_str_associate()"); } VALUE rb_str_associated(VALUE str) { - rb_warn("rb_str_associated() is only for internal use and deprecated; do not use"); - return str_associated(str); + ONLY_FOR_INTERNAL_USE("rb_str_associated()"); } /* diff --git a/vm.c b/vm.c index 77f57d9839..94fbfdda48 100644 --- a/vm.c +++ b/vm.c @@ -459,8 +459,7 @@ rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp) void rb_frame_pop(void) { - rb_thread_t *th = GET_THREAD(); - vm_pop_frame(th); + ONLY_FOR_INTERNAL_USE("rb_frame_pop()"); } /* at exit */ diff --git a/vm_method.c b/vm_method.c index 2d3e78c303..90d543793a 100644 --- a/vm_method.c +++ b/vm_method.c @@ -83,9 +83,7 @@ rb_class_clear_method_cache(VALUE klass, VALUE arg) void rb_clear_cache(void) { - rb_warning("rb_clear_cache() is deprecated."); - INC_GLOBAL_METHOD_STATE(); - INC_GLOBAL_CONSTANT_STATE(); + ONLY_FOR_INTERNAL_USE("rb_clear_cache()"); } void -- cgit v1.2.3