aboutsummaryrefslogtreecommitdiff
path: root/clang/docs
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2024-03-27 15:56:19 -0700
committerGitHub <noreply@github.com>2024-03-27 16:56:19 -0600
commit14ba782a87e16e9e15460a51f50e67e2744c26d9 (patch)
tree8803786e8a62c8b6fc08c6b9fc4542869e38cac2 /clang/docs
parent0a17eedf7b0c1168999e7ac0492015c64c1fbef4 (diff)
downloadllvm-14ba782a87e16e9e15460a51f50e67e2744c26d9.zip
llvm-14ba782a87e16e9e15460a51f50e67e2744c26d9.tar.gz
llvm-14ba782a87e16e9e15460a51f50e67e2744c26d9.tar.bz2
[Clang][Sema] Allow flexible arrays in unions and alone in structs (#84428)
GNU and MSVC have extensions where flexible array members (or their equivalent) can be in unions or alone in structs. This is already fully supported in Clang through the 0-sized array ("fake flexible array") extension or when C99 flexible array members have been syntactically obfuscated. Clang needs to explicitly allow these extensions directly for C99 flexible arrays, since they are common code patterns in active use by the Linux kernel (and other projects). Such projects have been using either 0-sized arrays (which is considered deprecated in favor of C99 flexible array members) or via obfuscated syntax, both of which complicate their code bases. For example, these do not error by default: ``` union one { int a; int b[0]; }; union two { int a; struct { struct { } __empty; int b[]; }; }; ``` But this does: ``` union three { int a; int b[]; }; ``` Remove the default error diagnostics for this but continue to provide warnings under Microsoft or GNU extensions checks. This will allow for a seamless transition for code bases away from 0-sized arrays without losing existing code patterns. Add explicit checking for the warnings under various constructions. Additionally fixes a CodeGen bug with flexible array members in unions in C++, which was found when adding a testcase for: ``` union { char x[]; } z = {0}; ``` which only had Sema tests originally. Fixes #84565
Diffstat (limited to 'clang/docs')
-rw-r--r--clang/docs/ReleaseNotes.rst3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0fdd9e3..ccc399d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -304,6 +304,9 @@ Improvements to Clang's diagnostics
annotated with the ``clang::always_destroy`` attribute.
Fixes #GH68686, #GH86486
+- ``-Wmicrosoft``, ``-Wgnu``, or ``-pedantic`` is now required to diagnose C99
+ flexible array members in a union or alone in a struct. Fixes GH#84565.
+
Improvements to Clang's time-trace
----------------------------------