Skip to content

Commit 9ed3d85

Browse files
SlaterLatiaoAaronBallman
authored andcommitted
[clang][diagnostics] Add -Wpacked-non-pod to -Wall
Users will be informed when non-POD is not packed using -Wall. This is also consistent with GCC. Fixes #60832 Differential Revision: https://reviews.llvm.org/D151162
1 parent 11ea40c commit 9ed3d85

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ Improvements to Clang's diagnostics
307307
(`#62850: <https://github.com/llvm/llvm-project/issues/62850>`_).
308308
- Clang now warns when any predefined macro is undefined or redefined, instead
309309
of only some of them.
310+
- ``-Wpacked-non-pod`` is now included in ``-Wall``.
311+
(`#60832: <https://github.com/llvm/llvm-project/issues/60832>`_)
310312

311313
Bug Fixes in This Version
312314
-------------------------

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ def Consumed : DiagGroup<"consumed">;
10601060
// warning should be active _only_ when -Wall is passed in, mark it as
10611061
// DefaultIgnore in addition to putting it here.
10621062
def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool,
1063-
MisleadingIndentation]>;
1063+
MisleadingIndentation, PackedNonPod]>;
10641064

10651065
// Warnings that should be in clang-cl /w4.
10661066
def : DiagGroup<"CL4", [All, Extra]>;

clang/test/CodeGenCXX/warn-padded-packed.cpp renamed to clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
// RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked -verify=expected,top %s -emit-llvm-only
2-
// RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked -verify=expected,abi15 -fclang-abi-compat=15 %s -emit-llvm-only
1+
// RUN: %clang_cc1 -Wpadded -Wpacked -verify=expected,top %s -emit-llvm-only
2+
// RUN: %clang_cc1 -Wpadded -Wpacked -verify=expected,abi15 -fclang-abi-compat=15 %s -emit-llvm-only
3+
// -Wpacked-non-pod itself should not emit the "packed attribute is unnecessary" warnings.
4+
// RUN: %clang_cc1 -Wpacked-non-pod -verify=top %s -emit-llvm-only
5+
// -Wall should not emit the "packed attribute is unnecessary" warnings without -Wpacked.
6+
// RUN: %clang_cc1 -Wall -verify=top %s -emit-llvm-only
7+
38

49
struct S1 {
510
char c;

clang/test/Misc/warning-wall.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ CHECK-NEXT: -Wdangling-else
9999
CHECK-NEXT: -Wswitch
100100
CHECK-NEXT: -Wswitch-bool
101101
CHECK-NEXT: -Wmisleading-indentation
102+
CHECK-NEXT: -Wpacked-non-pod
102103

103104

104105
CHECK-NOT:-W

0 commit comments

Comments
 (0)