Suppress -Wmissing-braces warning when aggregate-initializing a struct with a single field that is itself an aggregate.
In C++, such initialization of std::array<T, N> types is guaranteed to work by
the standard, is completely idiomatic, and the "suggested" alternative from
Clang was technically invalid.
llvm-svn: 314838
diff --git a/clang/test/Sema/zero-initializer.c b/clang/test/Sema/zero-initializer.c
index 472eed9..0ab410d 100644
--- a/clang/test/Sema/zero-initializer.c
+++ b/clang/test/Sema/zero-initializer.c
@@ -6,6 +6,7 @@
struct A { int a; };
struct B { struct A a; };
struct C { struct B b; };
+struct D { struct C c; int n; };
int main(void)
{
@@ -20,7 +21,8 @@
struct bar n = { { 0 }, { 9, 9 } }; // no-warning
struct bar o = { { 9 }, { 9, 9 } }; // expected-warning {{missing field 'y' initializer}}
struct C p = { 0 }; // no-warning
- struct C q = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{suggest braces around initialization of subobject}}
+ struct C q = { 9 }; // warning suppressed for struct with single element
+ struct D r = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
f = (struct foo ) { 0 }; // no-warning
g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' initializer}}
h = (struct foo ) { 9, 9 }; // no-warning
@@ -32,7 +34,8 @@
n = (struct bar) { { 0 }, { 9, 9 } }; // no-warning
o = (struct bar) { { 9 }, { 9, 9 } }; // expected-warning {{missing field 'y' initializer}}
p = (struct C) { 0 }; // no-warning
- q = (struct C) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{suggest braces around initialization of subobject}}
+ q = (struct C) { 9 }; // warning suppressed for struct with single element
+ r = (struct D) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
return 0;
}