Don't use Clang nullability qualifiers in strict ISO C mode - #3074
Merged
Conversation
`_Nullable` and `_Nonnull` are Clang extensions, so compiling the rbs
headers in a strict ISO C dialect emits `-Wnullability-extension`, which
`-pedantic-errors` turns into an error:
include/rbs/ast.h:166:44: error: type nullability specifier '_Nonnull' is a Clang extension [-Werror,-Wnullability-extension]
166 | void rbs_node_list_append(rbs_node_list_t *RBS_NONNULL list, rbs_node_t *RBS_NONNULL node);
| ^
include/rbs/defines.h:93:21: note: expanded from macro 'RBS_NONNULL'
93 | #define RBS_NONNULL _Nonnull
This breaks embedders that build the extension with a conforming dialect.
CRuby's `omnibus compilations` CI job compiles the bundled gems with
`-std=c99 -Werror=pedantic -pedantic-errors` (and c11/c17/c2x), so
building `ext/rbs_extension` there fails once rbs is bundled.
Expand the macros to nothing when `__STRICT_ANSI__` is defined, which is
exactly the case where the qualifiers are not accepted. Non-strict builds,
including Clang's default `-std=gnu*` dialects, keep the annotations, so
nothing is lost for the static analyzer.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vqx4FeruSY2rScP3frptqZ
This was referenced Aug 10, 2026
soutaro
added a commit
that referenced
this pull request
Aug 10, 2026
Backport #3074 to 4.1: Don't use Clang nullability qualifiers in strict ISO C mode
Merged
Merged
soutaro
pushed a commit
that referenced
this pull request
Aug 23, 2026
`RBS::VERSION` becomes 4.2.0, `Gemfile.lock` is regenerated with the bump, and the 4.2.0.pre.1 section of CHANGELOG.md is replaced by the 4.2.0 section that folds it in. The changelog starts at `v4.1.2`, the latest release proper reachable from `master`: a release proper skips the prerelease tags, so everything written up under 4.2.0.pre.1 is in this section as well. #3074 and #3073 appear under 4.1.3 too, which backported them. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_Nullableand_Nonnullare Clang extensions, so compiling the rbs headers in a strict ISO C dialect emits-Wnullability-extension, which-pedantic-errorsturns into an error:CRuby's
omnibus compilations, #5job builds with-std=c99 -Werror=pedantic -pedantic-errors(and c11/c17/c2x), soext/rbs_extensionfails to compile there once rbs 4.1.x is bundled — see ruby/ruby#18274. rbs 4.0.3 had no nullability macros, so this is new in 4.1.x.Expand the macros to nothing when
__STRICT_ANSI__is defined, which is exactly the case where the qualifiers are rejected. Feature-test macros don't work here: both__has_feature(nullability)and__has_extension(nullability)report1even under-std=c99, since the extension is available — it just warns.Clang's default
-std=gnu*dialects keep the annotations, so nothing is lost for the static analyzer. Verified with clang 18: all ofsrc/compiles cleanly under c99/c11/c17/c2x with-pedantic-errors, and-std=gnu17still expands to_Nonnull/_Nullable.