Commit e197225
committed
Don't use Clang nullability qualifiers in strict ISO C mode
`_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_01Vqx4FeruSY2rScP3frptqZ1 parent da71a3b commit e197225
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
90 | 95 | | |
91 | | - | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
| |||
0 commit comments