Skip to content

Commit a569bc0

Browse files
committed
add include/ruby/backward/cxxanyargs.hpp
Compilation of extension libraries written in C++ are reportedly broken due to #2404 The root cause of this issue was that the definition of ANYARGS differ between C and C++, and that of C++ is incompatible with the updated ones. We are using the incompatibility against itself. In C++ two distinct function prototypes can be overloaded. We provide the old, ANYARGSed prototypes in addition to the current granular ones; and let the older ones warn about types.
1 parent d6a94cf commit a569bc0

File tree

5 files changed

+399
-6
lines changed

5 files changed

+399
-6
lines changed

eval.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,13 +947,27 @@ rb_need_block(void)
947947
VALUE
948948
rb_rescue2(VALUE (* b_proc) (VALUE), VALUE data1,
949949
VALUE (* r_proc) (VALUE, VALUE), VALUE data2, ...)
950+
{
951+
va_list ap;
952+
va_start(ap, data2);
953+
return rb_vrescue2(b_proc, data1, r_proc, data2, ap);
954+
va_end(ap);
955+
}
956+
957+
/*!
958+
* \copydoc rb_rescue2
959+
* \param[in] args exception classes, terminated by 0.
960+
*/
961+
VALUE
962+
rb_vrescue2(VALUE (* b_proc) (VALUE), VALUE data1,
963+
VALUE (* r_proc) (VALUE, VALUE), VALUE data2,
964+
va_list args)
950965
{
951966
enum ruby_tag_type state;
952967
rb_execution_context_t * volatile ec = GET_EC();
953968
rb_control_frame_t *volatile cfp = ec->cfp;
954969
volatile VALUE result = Qfalse;
955970
volatile VALUE e_info = ec->errinfo;
956-
va_list args;
957971

958972
EC_PUSH_TAG(ec);
959973
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
@@ -976,14 +990,12 @@ rb_rescue2(VALUE (* b_proc) (VALUE), VALUE data1,
976990
int handle = FALSE;
977991
VALUE eclass;
978992

979-
va_init_list(args, data2);
980993
while ((eclass = va_arg(args, VALUE)) != 0) {
981994
if (rb_obj_is_kind_of(ec->errinfo, eclass)) {
982995
handle = TRUE;
983996
break;
984997
}
985998
}
986-
va_end(args);
987999

9881000
if (handle) {
9891001
result = Qnil;

0 commit comments

Comments
 (0)