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