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

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.
This commit is contained in:
Nobuyoshi Nakada 2021-09-27 14:47:52 +09:00 committed by GitHub
parent 582602d142
commit f7ffe9dbde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2021-09-27 14:48:20 +09:00
Merged: https://github.com/ruby/ruby/pull/4898

Merged-By: nobu <nobu@ruby-lang.org>
3 changed files with 6 additions and 13 deletions

View file

@ -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 */