diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-03 20:36:00 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-03 20:36:00 +0000 |
| commit | 283e2076f6a6f23629475a25c64173843e72cf61 (patch) | |
| tree | bd89ce68e591932aa9361e034111d3c9959879c9 /clang/test/Sema/zero-initializer.c | |
| parent | 389b7cedc311c785d9060d83197b555d227b4d7d (diff) | |
| download | bcm5719-llvm-283e2076f6a6f23629475a25c64173843e72cf61.tar.gz bcm5719-llvm-283e2076f6a6f23629475a25c64173843e72cf61.zip | |
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
Diffstat (limited to 'clang/test/Sema/zero-initializer.c')
| -rw-r--r-- | clang/test/Sema/zero-initializer.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/test/Sema/zero-initializer.c b/clang/test/Sema/zero-initializer.c index 472eed9517f..0ab410d4c6d 100644 --- a/clang/test/Sema/zero-initializer.c +++ b/clang/test/Sema/zero-initializer.c @@ -6,6 +6,7 @@ struct bar { struct foo a; struct foo b; }; 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 @@ int main(void) 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 @@ int main(void) 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; } |

