| 1 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s |
| 2 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s |
| 3 | |
| 4 | template <typename T> struct Foo { |
| 5 | struct SubFoo { |
| 6 | int bar1; |
| 7 | int bar2; |
| 8 | }; |
| 9 | |
| 10 | static void Test() { SubFoo sf = {.bar1 = 10, .bar2 = 20}; } // Expected no warning |
| 11 | }; |
| 12 | |
| 13 | void foo() { |
| 14 | Foo<int>::Test(); |
| 15 | Foo<bool>::Test(); |
| 16 | Foo<float>::Test(); |
| 17 | } |
| 18 | |
| 19 | template <typename T> struct Bar { |
| 20 | struct SubFoo { |
| 21 | int bar1; |
| 22 | int bar2; |
| 23 | }; |
| 24 | |
| 25 | static void Test() { SubFoo sf = {.bar1 = 10, // expected-note 2 {{previous initialization is here}} |
| 26 | .bar1 = 20}; } // expected-warning 2 {{initializer overrides prior initialization of this subobject}} |
| 27 | }; |
| 28 | |
| 29 | void bar() { |
| 30 | Bar<int>::Test(); // expected-note {{in instantiation of member function 'Bar<int>::Test' requested here}} |
| 31 | Bar<bool>::Test(); // expected-note {{in instantiation of member function 'Bar<bool>::Test' requested here}} |
| 32 | } |
| 33 | |