[clang] 9168974 - Reapply: [clang][diagnostics] Adding -Wpacked-non-pod to -Wall
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu May 25 13:02:06 PDT 2023
Author: Zenong Zhang
Date: 2023-05-25T13:02:00-07:00
New Revision: 91689744477843a588f701fdc598ccff3cbbc8fb
URL: https://github.com/llvm/llvm-project/commit/91689744477843a588f701fdc598ccff3cbbc8fb
DIFF: https://github.com/llvm/llvm-project/commit/91689744477843a588f701fdc598ccff3cbbc8fb.diff
LOG: Reapply: [clang][diagnostics] Adding -Wpacked-non-pod to -Wall
Users will be informed when non-POD is not packed using -Wall. This
is also consistent with GCC.
Fixes PR#60832.
Differential Revision: https://reviews.llvm.org/D151162
Added:
clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
Modified:
clang/include/clang/Basic/DiagnosticGroups.td
clang/test/Misc/warning-wall.c
Removed:
clang/test/CodeGenCXX/warn-padded-packed.cpp
################################################################################
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 08b8f02460c16..9944fa87aba23 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1060,7 +1060,7 @@ def Consumed : DiagGroup<"consumed">;
// warning should be active _only_ when -Wall is passed in, mark it as
// DefaultIgnore in addition to putting it here.
def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool,
- MisleadingIndentation]>;
+ MisleadingIndentation, PackedNonPod]>;
// Warnings that should be in clang-cl /w4.
def : DiagGroup<"CL4", [All, Extra]>;
diff --git a/clang/test/CodeGenCXX/warn-padded-packed.cpp b/clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
similarity index 93%
rename from clang/test/CodeGenCXX/warn-padded-packed.cpp
rename to clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
index c51a6c9443f6e..5402e21e3a5b8 100644
--- a/clang/test/CodeGenCXX/warn-padded-packed.cpp
+++ b/clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
@@ -1,5 +1,10 @@
// RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked -verify=expected,top %s -emit-llvm-only
// RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked -verify=expected,abi15 -fclang-abi-compat=15 %s -emit-llvm-only
+// -Wpacked-non-pod itself should not emit the "packed attribute is unnecessary" warnings.
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod -verify=top %s -emit-llvm-only
+// -Wall should not emit the "packed attribute is unnecessary" warnings without -Wpacked.
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wall -verify=top %s -emit-llvm-only
+
struct S1 {
char c;
diff --git a/clang/test/Misc/warning-wall.c b/clang/test/Misc/warning-wall.c
index e57c5d6d501da..1c74759ce6161 100644
--- a/clang/test/Misc/warning-wall.c
+++ b/clang/test/Misc/warning-wall.c
@@ -99,6 +99,7 @@ CHECK-NEXT: -Wdangling-else
CHECK-NEXT: -Wswitch
CHECK-NEXT: -Wswitch-bool
CHECK-NEXT: -Wmisleading-indentation
+CHECK-NEXT: -Wpacked-non-pod
CHECK-NOT:-W
More information about the cfe-commits
mailing list