mattst88 wrote:

I've switched to @AaronBallman's suggestion. The PR now only changes
`ext_c23_bitint_suffix` from `ExtWarn` to `Extension`. There is no GNU-mode 
special
case left: `ext_bitint_suffix_in_gnu_mode` is gone and both `GNUMode` arms are
reverted, so `PPExpressions.cpp` and `SemaExpr.cpp` are untouched by this PR.

@Sirraide asked what we warn about by default in GNU mode and what we don't. 
Looking
into that, I found clang already gives two different answers for this one 
feature:

```
DiagnosticParseKinds.td:1816   ext_bit_int            Extension   
InGroup<BitIntExtension>   # the type
DiagnosticCommonKinds.td:240   ext_c23_bitint_suffix  ExtWarn     InGroup<C23>  
             # the suffix
```

`-std=c11` accepts `_BitInt(8)` silently but warns on `0uwb`. You need 
`-pedantic`
to hear about the type. Within `-Wc23-extensions`, 7 of the 14 diagnostics are
already `Extension` (`ext_c_nullptr`, `ext_c_empty_initializer`,
`ext_binary_literal`, `ext_c23_enum_fixed_underlying_type`,
`warn_ext_c23_attributes`, `ext_type_defined_in_offsetof`,
`ext_c23_enum_value_not_int`), so this makes it 8 of 14 rather than introducing 
a
new policy.

I should also correct my own premise. I claimed GCC's behaviour here was
GNU-mode-specific. It isn't. GCC applies the same rule to the C23 features it
accepts early, and `-std=gnu11` and `-std=c11` behave identically; only 
`-pedantic`
changes anything. So there was never a GNU/ISO split on the GCC side for this 
patch
to mirror.

Measured against gcc 15.3.0, counting only the suffix diagnostic:

| | GCC | this PR | before |
|---|---|---|---|
| `-std=c11` | silent | silent | warns |
| `-std=c11 -pedantic` | warns | warns | warns |
| `-std=gnu11` | silent | silent | warns |
| `-std=gnu11 -pedantic` | warns | warns | warns |
| explicit warning flag | warns | warns | warns |

`Extension` severity still fires when the group is enabled explicitly, so
`-Wc23-extensions` keeps reporting the suffix in every mode. That removes the
group-split tradeoff I flagged in the original description.

On `-Werror`: that argument doesn't hold up and I'm dropping it. Turning 
warnings into
errors is opting into exactly this. I'll fix the glibc side regardless of what
happens to this PR; it's on my TODO list.

Tests: `bitint-constants-compat.c` now covers `-pedantic`, an explicit
`-Wc23-extensions`, and the silent default, each in a strict ISO and a GNU C 
mode.
`AST/ByteCode/c.c` expectations move to the `pedantic` prefix. Reverting just 
the
`.td` line fails all three affected tests, so they're actually checking this.
`clang/test` is otherwise clean.

@cor3ntin, the conditional is back to its original two-way shape, so 
`DiagCompat`
no longer has a GNU arm in its way. The C23 pair is still convertible if you'd 
like
that; I'm happy to do it as a separate NFC change.


https://github.com/llvm/llvm-project/pull/217815
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to