summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-27 14:47:52 +0900
committerGitHub <noreply@github.com>2021-09-27 14:47:52 +0900
commitf7ffe9dbdeb2bebb4c9155fc391f0bab198bfb51 (patch)
tree24e273a2d906f2c40279f80eef46cbc6a36133fa /include
parent582602d142c7ea2b21cd7539c09976b078d7bbe9 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4898 Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'include')
-rw-r--r--include/ruby/internal/attr/nonnull.h2
1 files changed, 2 insertions, 0 deletions
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 */