[PATCH] D157503: Silently accept -Wgnu-empty-initializer
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 10 04:24:49 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG151214b40d86: Silently accept -Wgnu-empty-initializer (authored by aaron.ballman).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157503/new/
https://reviews.llvm.org/D157503
Files:
clang/include/clang/Basic/DiagnosticGroups.td
clang/test/Sema/empty-init.c
Index: clang/test/Sema/empty-init.c
===================================================================
--- /dev/null
+++ clang/test/Sema/empty-init.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -std=c2x -Wall -pedantic -fsyntax-only -verify=good
+// RUN: %clang_cc1 %s -std=c2x -Wpre-c2x-compat -fsyntax-only -verify=c2x
+// RUN: %clang_cc1 %s -std=c2x -Wpre-c2x-compat -Wno-gnu-empty-initializer -fsyntax-only -verify=c2x
+// RUN: %clang_cc1 %s -std=c2x -Wgnu-empty-initializer -fsyntax-only -verify=good
+// RUN: %clang_cc1 %s -std=c17 -Wall -pedantic -fsyntax-only -verify=c2x-ext
+// RUN: %clang_cc1 %s -std=c17 -Wgnu-empty-initializer -fsyntax-only -verify=good
+// RUN: %clang_cc1 %s -std=c17 -Wc2x-extensions -fsyntax-only -verify=c2x-ext
+// RUN: %clang_cc1 %s -std=c17 -Wpre-c2x-compat -fsyntax-only -verify=good
+
+// good-no-diagnostics
+
+// Empty brace initialization used to be a GNU extension, but the feature was
+// added to C2x. We now treat empty initialization as a C extension rather than
+// a GNU extension. Thus, -Wgnu-empty-initializer is always silently ignored.
+
+struct S {
+ int a;
+};
+
+struct S s = {}; /* c2x-warning {{use of an empty initializer is incompatible with C standards before C2x}}
+ c2x-ext-warning {{use of an empty initializer is a C2x extension}}
+ */
+
+void func(void) {
+ struct S s2 = {}; /* c2x-warning {{use of an empty initializer is incompatible with C standards before C2x}}
+ c2x-ext-warning {{use of an empty initializer is a C2x extension}}
+ */
+ (void)s2;
+}
+
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -20,6 +20,7 @@
// Empty DiagGroups are recognized by clang but ignored.
def ODR : DiagGroup<"odr">;
def : DiagGroup<"abi">;
+def : DiagGroup<"gnu-empty-initializer">; // Now a C extension, not GNU.
def AbsoluteValue : DiagGroup<"absolute-value">;
def MisspelledAssumption : DiagGroup<"misspelled-assumption">;
def UnknownAssumption : DiagGroup<"unknown-assumption">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157503.548968.patch
Type: text/x-patch
Size: 2214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230810/b99baa5b/attachment.bin>
More information about the cfe-commits
mailing list