diff --git a/clang/docs/DiagnosticsReference.rst b/clang/docs/DiagnosticsReference.rst --- a/clang/docs/DiagnosticsReference.rst +++ b/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:** diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/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>; def err_excess_initializers_in_char_array_initializer : Error< "excess elements in char array initializer">; def ext_excess_initializers_in_char_array_initializer : ExtWarn< diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c --- a/clang/test/Misc/warning-flags.c +++ b/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 diff --git a/clang/test/Sema/init.c b/clang/test/Sema/init.c --- a/clang/test/Sema/init.c +++ b/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);