[all-commits] [llvm/llvm-project] 576161: [C] Warn on uninitialized const objects (#137166)
Aaron Ballman via All-commits
all-commits at lists.llvm.org
Fri Apr 25 05:22:04 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 576161cb6069e2c7656a8ef530727a0f4aefff30
https://github.com/llvm/llvm-project/commit/576161cb6069e2c7656a8ef530727a0f4aefff30
Author: Aaron Ballman <aaron at aaronballman.com>
Date: 2025-04-25 (Fri, 25 Apr 2025)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticGroups.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/Parse/ParseStmt.cpp
M clang/lib/Sema/Sema.cpp
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaInit.cpp
M clang/test/C/C23/n2607.c
M clang/test/C/drs/dr1xx.c
M clang/test/Parser/typeof.c
M clang/test/Sema/assign.c
M clang/test/Sema/atomic-ops.c
M clang/test/Sema/block-return.c
M clang/test/Sema/builtins-bpf.c
M clang/test/Sema/builtins-elementwise-math.c
M clang/test/Sema/builtins-overflow.c
M clang/test/Sema/enable_if.c
M clang/test/Sema/implicit-decl.c
M clang/test/Sema/overloadable.c
M clang/test/Sema/sizeless-1.c
M clang/test/Sema/typedef-retain.c
M clang/test/Sema/varargs-x86-64.c
A clang/test/Sema/warn-default-const-init.c
M clang/test/Sema/warn-unused-function.c
M clang/test/SemaObjC/message.m
M clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
M clang/test/SemaOpenCL/invalid-block.cl
M clang/test/SemaOpenMP/atomic-capture-const-no-crash.c
Log Message:
-----------
[C] Warn on uninitialized const objects (#137166)
Unlike C++, C allows the definition of an uninitialized `const` object.
If the object has static or thread storage duration, it is still
zero-initialized, otherwise, the object is left uninitialized. In either
case, the code is not compatible with C++.
This adds a new diagnostic group, `-Wdefault-const-init-unsafe`, which
is on by default and diagnoses any definition of a `const` object which
remains uninitialized.
It also adds another new diagnostic group, `-Wdefault-const-init` (which
also enabled the `unsafe` variant) that diagnoses any definition of a
`const` object (including ones which are zero-initialized). This
diagnostic is off by default.
Finally, it adds `-Wdefault-const-init` to `-Wc++-compat`. GCC diagnoses
these situations under this flag.
Fixes #19297
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