1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-reorder -Wno-c99-designator -Winitializer-overrides %s
2 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-reorder -Wno-c99-designator -Woverride-init %s
4 template <typename T
> struct Foo
{
10 static void Test() { SubFoo sf
= {.bar1
= 10, .bar2
= 20}; } // Expected no warning
19 template <typename T
> struct Bar
{
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}}
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}}
46 foo n
= {.y
= 4, .x
= 5};
47 X arr
[2] = {[1] = 1, [0] = 2};
83 int a
, &b
, &c
; // expected-note 2{{here}}
86 .a
= 1, .c
= s1
.a
, .b
= s1
.a
90 }; // expected-error {{uninitialized}}
93 }; // expected-error {{uninitialized}}
96 // Check that we don't even think about whether holes in a designated
97 // initializer are zero-initializable if the holes are filled later.
98 namespace NoCheckingFilledHoles
{
99 template<typename T
> struct Error
{ using type
= typename
T::type
; }; // expected-error 3{{'::'}}
102 struct DefaultInitIsError
{
103 DefaultInitIsError(Error
<int[N
]> = {}); // expected-note 3{{instantiation}} expected-note 3{{passing}}
104 DefaultInitIsError(int, int);
110 DefaultInitIsError
<N
> e
;
126 }; // expected-note {{default function argument}}
130 }; // expected-note {{default function argument}}
142 template<int N
> struct Y
{ X
<N
> x
; };
144 .x
= {.a
= 1, .b
= 2}, // expected-note {{default function argument}}
154 namespace LargeArrayDesignator
{
162 void f(Y y
) = delete;
174 // OK. Would fail if checking {} against type A set the type of the
175 // initializer list to A, because ADL would find ADL::f, resulting in
177 void g() { f({}, {}); }