[all-commits] [llvm/llvm-project] 0b1886: [Clang] [Diagnostic] Extend DiagCompat() to C lang...
Sirraide via All-commits
all-commits at lists.llvm.org
Wed Jul 15 12:49:52 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0b18869a684febeb4144cd0213cef3163b8cb37e
https://github.com/llvm/llvm-project/commit/0b18869a684febeb4144cd0213cef3163b8cb37e
Author: Sirraide <aeternalmail at gmail.com>
Date: 2026-07-15 (Wed, 15 Jul 2026)
Changed paths:
M clang/bindings/python/tests/cindex/test_diagnostics.py
M clang/include/clang/Basic/Diagnostic.td
M clang/include/clang/Basic/DiagnosticIDs.h
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/Basic/DiagnosticIDs.cpp
M clang/lib/Parse/Parser.cpp
M clang/lib/Sema/SemaBase.cpp
M clang/lib/Sema/SemaExpr.cpp
M clang/lib/Sema/SemaStmt.cpp
M clang/lib/Sema/SemaType.cpp
Log Message:
-----------
[Clang] [Diagnostic] Extend DiagCompat() to C language modes (#209241)
This expands the compatibility warnings infrastructure added in #132348
to support C mode as well. Implementing this was actually fairly
straight-forward because we are only ever in C _or_ C++ mode, i.e.
during a single compilation we either emit only C compatibility warnings
or only C++ compatibility warnings. This means we can simply reuse the
existing code and just check for different LangOpts depending on whether
we're in C or C++ mode.
Concretely, this means that instead of e.g.
```
def ext_c2y_alignof_incomplete_array : Extension<
"'alignof' on an incomplete array type is a C2y extension">,
InGroup<C2y>;
def warn_c2y_compat_alignof_incomplete_array : Warning<
"'alignof' on an incomplete array type is incompatible with C standards "
"before C2y">, InGroup<CPre2yCompat>, DefaultIgnore;
```
you can now simply write
```
defm alignof_incomplete_array : C2yCompat<"'alignof' on an incomplete array type is">;
```
And when emitting the warning(s), code such as
```
Diag(OpLoc, getLangOpts().C2y
? diag::warn_c2y_compat_alignof_incomplete_array
: diag::ext_c2y_alignof_incomplete_array);
```
can now be replaced with
```
DiagCompat(OpLoc, diag_compat::alignof_incomplete_array);
```
I've also migrated the C compatibility warnings in
DiagnosticSemaKinds.td to use the new system to make sure that
everything is working properly.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list