[PATCH] D79244: [Sema] Put existing warning under -Wexcess-initializers

Richard Sandiford via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 1 17:14:22 PDT 2020


rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
rsandifo-arm added a parent revision: D79236: [docs] Regenerate DiagnosticsReference.rst.
rsandifo-arm added a child revision: D76689: [Sema][SVE] Fix handling of initialisers for built-in SVE types.

I have a follow-on patch that uses an alternative wording for
this warning in some cases.  This patch puts it under its own
-W option in order to avoid a regression in Misc/warning-flags.c.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79244

Files:
  clang/docs/DiagnosticsReference.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Misc/warning-flags.c
  clang/test/Sema/init.c


Index: clang/test/Sema/init.c
===================================================================
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -121,6 +121,10 @@
 };
 
 struct foo2 bar3 = { 1, 2 }; // expected-warning{{excess elements in struct initializer}}
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wexcess-initializers"
+struct foo2 bar3_silent = { 1, 2 };
+#pragma clang diagnostic pop
 
 int* ptest1 = __builtin_choose_expr(1, (int*)0, (int*)0);
 
Index: clang/test/Misc/warning-flags.c
===================================================================
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -18,8 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (75):
-CHECK-NEXT:   ext_excess_initializers
+CHECK: Warnings without flags (74):
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5381,7 +5381,8 @@
 def err_excess_initializers : Error<
   "excess elements in %select{array|vector|scalar|union|struct}0 initializer">;
 def ext_excess_initializers : ExtWarn<
-  "excess elements in %select{array|vector|scalar|union|struct}0 initializer">;
+  "excess elements in %select{array|vector|scalar|union|struct}0 initializer">,
+  InGroup<DiagGroup<"excess-initializers">>;
 def err_excess_initializers_in_char_array_initializer : Error<
   "excess elements in char array initializer">;
 def ext_excess_initializers_in_char_array_initializer : ExtWarn<
Index: clang/docs/DiagnosticsReference.rst
===================================================================
--- clang/docs/DiagnosticsReference.rst
+++ clang/docs/DiagnosticsReference.rst
@@ -4481,6 +4481,27 @@
 +-----------------------------------------------------------------------------------------------------------------------------+
 
 
+-Wexcess-initializers
+---------------------
+This diagnostic is enabled by default.
+
+**Diagnostic text:**
+
++-----------------------------------------------------------------+--------------------+-------------------------------+
+|:warning:`warning:` |nbsp| :diagtext:`excess elements in` |nbsp| |+------------------+| |nbsp| :diagtext:`initializer`|
+|                                                                 ||:diagtext:`array` ||                               |
+|                                                                 |+------------------+|                               |
+|                                                                 ||:diagtext:`vector`||                               |
+|                                                                 |+------------------+|                               |
+|                                                                 ||:diagtext:`scalar`||                               |
+|                                                                 |+------------------+|                               |
+|                                                                 ||:diagtext:`union` ||                               |
+|                                                                 |+------------------+|                               |
+|                                                                 ||:diagtext:`struct`||                               |
+|                                                                 |+------------------+|                               |
++-----------------------------------------------------------------+--------------------+-------------------------------+
+
+
 -Wexit-time-destructors
 -----------------------
 **Diagnostic text:**


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79244.261475.patch
Type: text/x-patch
Size: 3968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200502/5c1f7965/attachment-0001.bin>


More information about the cfe-commits mailing list