Skip to content

Backport #3074 to 4.1: Don't use Clang nullability qualifiers in strict ISO C mode - #3075

Merged
soutaro merged 1 commit into
aaa-4.1.xfrom
claude/rbs-3074-backport-dh5jwk
Aug 10, 2026
Merged

Backport #3074 to 4.1: Don't use Clang nullability qualifiers in strict ISO C mode#3075
soutaro merged 1 commit into
aaa-4.1.xfrom
claude/rbs-3074-backport-dh5jwk

Conversation

@soutaro

@soutaro soutaro commented Aug 10, 2026

Copy link
Copy Markdown
Member

Backports #3074 to the aaa-4.1.x branch, cherry-picked with -x.

_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

CRuby's omnibus compilations, #5 job builds with -std=c99 -Werror=pedantic -pedantic-errors (and c11/c17/c2x), so ext/rbs_extension fails 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, which makes the fix only reach CRuby through this branch.

The macros expand to nothing when __STRICT_ANSI__ is defined, which is exactly the case where the qualifiers are rejected. Clang's default -std=gnu* dialects keep the annotations, so nothing is lost for the static analyzer.

The cherry-pick applied cleanly with no conflicts.

Verification

  • clang -std=c99 -pedantic-errors -Werror on src/ast.c fails on aaa-4.1.x as it stands and passes with this commit, and the same holds for -std=c11 and -std=c17.
  • rake compile and a parser smoke test pass.

Generated by Claude Code

`_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
(cherry picked from commit e197225)
@soutaro
soutaro merged commit 7920265 into aaa-4.1.x Aug 10, 2026
25 checks passed
@soutaro
soutaro deleted the claude/rbs-3074-backport-dh5jwk branch August 10, 2026 07:18
@soutaro soutaro mentioned this pull request Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants