1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Enable RUBY_ASSERT_MESG_WHEN when RUBY_DEBUG is turned on

This commit is contained in:
Nobuyoshi Nakada 2019-07-15 11:00:16 +09:00
parent 05cc87df1b
commit a7fdb22373
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -20,15 +20,16 @@ NORETURN(void rb_assert_failure(const char *, int, const char *, const char *));
((expr) ? (void)0 : RUBY_ASSERT_FAIL(mesg))
#ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P
# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
((RUBY_DEBUG+0) ? RUBY_ASSERT_MESG((expr), mesg) : \
__builtin_choose_expr( \
__builtin_constant_p(cond), \
__builtin_choose_expr(cond, RUBY_ASSERT_MESG(expr, mesg), (void)0), \
RUBY_ASSERT_MESG(!(cond) || (expr), mesg))
RUBY_ASSERT_MESG(!(cond) || (expr), mesg)))
#else
# define RUBY_ASSERT_MESG_WHEN(cond, expr, mesg) \
RUBY_ASSERT_MESG(!(cond) || (expr), mesg)
RUBY_ASSERT_MESG(!((RUBY_DEBUG+0) || (cond)) || (expr), mesg)
#endif
#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(RUBY_DEBUG+(!RUBY_NDEBUG+0), expr, #expr)
#define RUBY_ASSERT(expr) RUBY_ASSERT_MESG_WHEN((!RUBY_NDEBUG+0), expr, #expr)
#define RUBY_ASSERT_WHEN(cond, expr) RUBY_ASSERT_MESG_WHEN(cond, expr, #expr)
#define RUBY_ASSERT_ALWAYS(expr) RUBY_ASSERT_MESG_WHEN(TRUE, expr, #expr)