From f7ffe9dbdeb2bebb4c9155fc391f0bab198bfb51 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 27 Sep 2021 14:47:52 +0900 Subject: Introduce `RBIMPL_NONNULL_ARG` macro Runtime assertion for the argument declared as non-null. This macro does nothing if `RBIMPL_ATTR_NONNULL` is effective, otherwise asserts that the argument is non-null. --- include/ruby/internal/attr/nonnull.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/ruby') diff --git a/include/ruby/internal/attr/nonnull.h b/include/ruby/internal/attr/nonnull.h index 874f4236c0..778d5be208 100644 --- a/include/ruby/internal/attr/nonnull.h +++ b/include/ruby/internal/attr/nonnull.h @@ -25,8 +25,10 @@ /** Wraps (or simulates) `__attribute__((nonnull))` */ #if RBIMPL_HAS_ATTRIBUTE(nonnull) # define RBIMPL_ATTR_NONNULL(list) __attribute__((__nonnull__ list)) +# define RBIMPL_NONNULL_ARG(arg) RBIMPL_ASSERT_NOTHING #else # define RBIMPL_ATTR_NONNULL(list) /* void */ +# define RBIMPL_NONNULL_ARG(arg) RUBY_ASSERT(arg) #endif #endif /* RBIMPL_ATTR_NONNULL_H */ -- cgit v1.2.3