1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++0x -fsyntax-only -fexceptions -verify %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc struct one { char c[1]; }; 4f4a2713aSLionel Sambuc struct two { char c[2]; }; 5f4a2713aSLionel Sambuc 6f4a2713aSLionel Sambuc namespace std { 7f4a2713aSLionel Sambuc typedef decltype(sizeof(int)) size_t; 8f4a2713aSLionel Sambuc 9f4a2713aSLionel Sambuc // libc++'s implementation 10f4a2713aSLionel Sambuc template <class _E> 11f4a2713aSLionel Sambuc class initializer_list 12f4a2713aSLionel Sambuc { 13f4a2713aSLionel Sambuc const _E* __begin_; 14f4a2713aSLionel Sambuc size_t __size_; 15f4a2713aSLionel Sambuc initializer_list(const _E * __b,size_t __s)16f4a2713aSLionel Sambuc initializer_list(const _E* __b, size_t __s) 17f4a2713aSLionel Sambuc : __begin_(__b), 18f4a2713aSLionel Sambuc __size_(__s) 19f4a2713aSLionel Sambuc {} 20f4a2713aSLionel Sambuc 21f4a2713aSLionel Sambuc public: 22f4a2713aSLionel Sambuc typedef _E value_type; 23f4a2713aSLionel Sambuc typedef const _E& reference; 24f4a2713aSLionel Sambuc typedef const _E& const_reference; 25f4a2713aSLionel Sambuc typedef size_t size_type; 26f4a2713aSLionel Sambuc 27f4a2713aSLionel Sambuc typedef const _E* iterator; 28f4a2713aSLionel Sambuc typedef const _E* const_iterator; 29f4a2713aSLionel Sambuc initializer_list()30f4a2713aSLionel Sambuc initializer_list() : __begin_(nullptr), __size_(0) {} 31f4a2713aSLionel Sambuc size() const32f4a2713aSLionel Sambuc size_t size() const {return __size_;} begin() const33f4a2713aSLionel Sambuc const _E* begin() const {return __begin_;} end() const34f4a2713aSLionel Sambuc const _E* end() const {return __begin_ + __size_;} 35f4a2713aSLionel Sambuc }; 36f4a2713aSLionel Sambuc } 37f4a2713aSLionel Sambuc 38f4a2713aSLionel Sambuc namespace objects { 39f4a2713aSLionel Sambuc 40f4a2713aSLionel Sambuc struct X1 { X1(int); }; 41f4a2713aSLionel Sambuc struct X2 { explicit X2(int); }; // expected-note {{constructor declared here}} 42f4a2713aSLionel Sambuc 43f4a2713aSLionel Sambuc template <int N> 44f4a2713aSLionel Sambuc struct A { Aobjects::A45f4a2713aSLionel Sambuc A() { static_assert(N == 0, ""); } Aobjects::A46f4a2713aSLionel Sambuc A(int, double) { static_assert(N == 1, ""); } 47f4a2713aSLionel Sambuc }; 48f4a2713aSLionel Sambuc 49f4a2713aSLionel Sambuc template <int N> 50f4a2713aSLionel Sambuc struct F { Fobjects::F51f4a2713aSLionel Sambuc F() { static_assert(N == 0, ""); } Fobjects::F52f4a2713aSLionel Sambuc F(int, double) { static_assert(N == 1, ""); } Fobjects::F53f4a2713aSLionel Sambuc F(std::initializer_list<int>) { static_assert(N == 3, ""); } 54f4a2713aSLionel Sambuc }; 55f4a2713aSLionel Sambuc 56f4a2713aSLionel Sambuc template <int N> 57f4a2713aSLionel Sambuc struct D { Dobjects::D58f4a2713aSLionel Sambuc D(std::initializer_list<int>) { static_assert(N == 0, ""); } // expected-note 1 {{candidate}} Dobjects::D59f4a2713aSLionel Sambuc D(std::initializer_list<double>) { static_assert(N == 1, ""); } // expected-note 1 {{candidate}} 60f4a2713aSLionel Sambuc }; 61f4a2713aSLionel Sambuc 62f4a2713aSLionel Sambuc template <int N> 63f4a2713aSLionel Sambuc struct E { Eobjects::E64f4a2713aSLionel Sambuc E(int, int) { static_assert(N == 0, ""); } Eobjects::E65f4a2713aSLionel Sambuc E(X1, int) { static_assert(N == 1, ""); } 66f4a2713aSLionel Sambuc }; 67f4a2713aSLionel Sambuc overload_resolution()68f4a2713aSLionel Sambuc void overload_resolution() { 69f4a2713aSLionel Sambuc { A<0> a{}; } 70f4a2713aSLionel Sambuc { A<0> a = {}; } 71f4a2713aSLionel Sambuc { A<1> a{1, 1.0}; } 72f4a2713aSLionel Sambuc { A<1> a = {1, 1.0}; } 73f4a2713aSLionel Sambuc 74f4a2713aSLionel Sambuc { F<0> f{}; } 75f4a2713aSLionel Sambuc { F<0> f = {}; } 76f4a2713aSLionel Sambuc // Narrowing conversions don't affect viability. The next two choose 77f4a2713aSLionel Sambuc // the initializer_list constructor. 78*0a6a1f1dSLionel Sambuc { F<3> f{1, 1.0}; } // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} 79*0a6a1f1dSLionel Sambuc { F<3> f = {1, 1.0}; } // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} 80f4a2713aSLionel Sambuc { F<3> f{1, 2, 3, 4, 5, 6, 7, 8}; } 81f4a2713aSLionel Sambuc { F<3> f = {1, 2, 3, 4, 5, 6, 7, 8}; } 82f4a2713aSLionel Sambuc { F<3> f{1, 2, 3, 4, 5, 6, 7, 8}; } 83f4a2713aSLionel Sambuc { F<3> f{1, 2}; } 84f4a2713aSLionel Sambuc 85f4a2713aSLionel Sambuc { D<0> d{1, 2, 3}; } 86f4a2713aSLionel Sambuc { D<1> d{1.0, 2.0, 3.0}; } 87f4a2713aSLionel Sambuc { D<-1> d{1, 2.0}; } // expected-error {{ambiguous}} 88f4a2713aSLionel Sambuc 89f4a2713aSLionel Sambuc { E<0> e{1, 2}; } 90f4a2713aSLionel Sambuc } 91f4a2713aSLionel Sambuc explicit_implicit()92f4a2713aSLionel Sambuc void explicit_implicit() { 93f4a2713aSLionel Sambuc { X1 x{0}; } 94f4a2713aSLionel Sambuc { X1 x = {0}; } 95f4a2713aSLionel Sambuc { X2 x{0}; } 96f4a2713aSLionel Sambuc { X2 x = {0}; } // expected-error {{constructor is explicit}} 97f4a2713aSLionel Sambuc } 98f4a2713aSLionel Sambuc 99f4a2713aSLionel Sambuc struct C { 100f4a2713aSLionel Sambuc C(); 101f4a2713aSLionel Sambuc C(int, double); 102f4a2713aSLionel Sambuc C(int, int); 103f4a2713aSLionel Sambuc 104f4a2713aSLionel Sambuc int operator[](C); 105f4a2713aSLionel Sambuc }; 106f4a2713aSLionel Sambuc function_call()107f4a2713aSLionel Sambuc C function_call() { 108f4a2713aSLionel Sambuc void takes_C(C); 109f4a2713aSLionel Sambuc takes_C({1, 1.0}); 110f4a2713aSLionel Sambuc 111f4a2713aSLionel Sambuc C c; 112f4a2713aSLionel Sambuc c[{1, 1.0}]; 113f4a2713aSLionel Sambuc 114f4a2713aSLionel Sambuc return {1, 1.0}; 115f4a2713aSLionel Sambuc } 116f4a2713aSLionel Sambuc inline_init()117f4a2713aSLionel Sambuc void inline_init() { 118f4a2713aSLionel Sambuc (void) C{1, 1.0}; 119f4a2713aSLionel Sambuc (void) new C{1, 1.0}; 120f4a2713aSLionel Sambuc (void) A<1>{1, 1.0}; 121f4a2713aSLionel Sambuc (void) new A<1>{1, 1.0}; 122f4a2713aSLionel Sambuc } 123f4a2713aSLionel Sambuc 124f4a2713aSLionel Sambuc struct B { // expected-note 2 {{candidate constructor}} 125f4a2713aSLionel Sambuc B(C, int, C); // expected-note {{candidate constructor not viable: cannot convert initializer list argument to 'objects::C'}} 126f4a2713aSLionel Sambuc }; 127f4a2713aSLionel Sambuc nested_init()128f4a2713aSLionel Sambuc void nested_init() { 129f4a2713aSLionel Sambuc B b1{{1, 1.0}, 2, {3, 4}}; 130f4a2713aSLionel Sambuc B b2{{1, 1.0, 4}, 2, {3, 4}}; // expected-error {{no matching constructor for initialization of 'objects::B'}} 131f4a2713aSLionel Sambuc } 132f4a2713aSLionel Sambuc overloaded_call()133f4a2713aSLionel Sambuc void overloaded_call() { 134f4a2713aSLionel Sambuc one ov1(B); // expected-note {{not viable: cannot convert initializer list}} 135f4a2713aSLionel Sambuc two ov1(C); // expected-note {{not viable: cannot convert initializer list}} 136f4a2713aSLionel Sambuc 137f4a2713aSLionel Sambuc static_assert(sizeof(ov1({})) == sizeof(two), "bad overload"); 138f4a2713aSLionel Sambuc static_assert(sizeof(ov1({1, 2})) == sizeof(two), "bad overload"); 139f4a2713aSLionel Sambuc static_assert(sizeof(ov1({{1, 1.0}, 2, {3, 4}})) == sizeof(one), "bad overload"); 140f4a2713aSLionel Sambuc 141f4a2713aSLionel Sambuc ov1({1}); // expected-error {{no matching function}} 142f4a2713aSLionel Sambuc 143f4a2713aSLionel Sambuc one ov2(int); 144f4a2713aSLionel Sambuc two ov2(F<3>); 145f4a2713aSLionel Sambuc static_assert(sizeof(ov2({1})) == sizeof(one), "bad overload"); // list -> int ranks as identity 146f4a2713aSLionel Sambuc static_assert(sizeof(ov2({1, 2, 3})) == sizeof(two), "bad overload"); // list -> F only viable 147f4a2713aSLionel Sambuc } 148f4a2713aSLionel Sambuc 149f4a2713aSLionel Sambuc struct G { // expected-note 6 {{not viable}} 150f4a2713aSLionel Sambuc // This is not an initializer-list constructor. 151f4a2713aSLionel Sambuc template<typename ...T> 152f4a2713aSLionel Sambuc G(std::initializer_list<int>, T ...); // expected-note 3 {{not viable}} 153f4a2713aSLionel Sambuc }; 154f4a2713aSLionel Sambuc 155f4a2713aSLionel Sambuc struct H { // expected-note 6 {{not viable}} 156f4a2713aSLionel Sambuc explicit H(int, int); // expected-note 3 {{not viable}} expected-note {{declared here}} 157f4a2713aSLionel Sambuc H(int, void*); // expected-note 3 {{not viable}} 158f4a2713aSLionel Sambuc }; 159f4a2713aSLionel Sambuc edge_cases()160f4a2713aSLionel Sambuc void edge_cases() { 161f4a2713aSLionel Sambuc // invalid (the first phase only considers init-list ctors) 162f4a2713aSLionel Sambuc // (for the second phase, no constructor is viable) 163f4a2713aSLionel Sambuc G g1{1, 2, 3}; // expected-error {{no matching constructor}} 164f4a2713aSLionel Sambuc (void) new G{1, 2, 3}; // expected-error {{no matching constructor}} 165f4a2713aSLionel Sambuc (void) G{1, 2, 3} // expected-error {{no matching constructor}} 166f4a2713aSLionel Sambuc 167f4a2713aSLionel Sambuc // valid (T deduced to <>). 168f4a2713aSLionel Sambuc G g2({1, 2, 3}); 169f4a2713aSLionel Sambuc (void) new G({1, 2, 3}); 170f4a2713aSLionel Sambuc (void) G({1, 2, 3}); 171f4a2713aSLionel Sambuc 172f4a2713aSLionel Sambuc // invalid 173f4a2713aSLionel Sambuc H h1({1, 2}); // expected-error {{no matching constructor}} 174f4a2713aSLionel Sambuc (void) new H({1, 2}); // expected-error {{no matching constructor}} 175f4a2713aSLionel Sambuc // FIXME: Bad diagnostic, mentions void type instead of init list. 176f4a2713aSLionel Sambuc (void) H({1, 2}); // expected-error {{no matching conversion}} 177f4a2713aSLionel Sambuc 178f4a2713aSLionel Sambuc // valid (by copy constructor). 179f4a2713aSLionel Sambuc H h2({1, nullptr}); 180f4a2713aSLionel Sambuc (void) new H({1, nullptr}); 181f4a2713aSLionel Sambuc (void) H({1, nullptr}); 182f4a2713aSLionel Sambuc 183f4a2713aSLionel Sambuc // valid 184f4a2713aSLionel Sambuc H h3{1, 2}; 185f4a2713aSLionel Sambuc (void) new H{1, 2}; 186f4a2713aSLionel Sambuc (void) H{1, 2}; 187f4a2713aSLionel Sambuc } 188f4a2713aSLionel Sambuc 189f4a2713aSLionel Sambuc struct memberinit { 190f4a2713aSLionel Sambuc H h1{1, nullptr}; 191f4a2713aSLionel Sambuc H h2 = {1, nullptr}; 192f4a2713aSLionel Sambuc H h3{1, 1}; 193f4a2713aSLionel Sambuc H h4 = {1, 1}; // expected-error {{constructor is explicit}} 194f4a2713aSLionel Sambuc }; 195f4a2713aSLionel Sambuc } 196f4a2713aSLionel Sambuc 197f4a2713aSLionel Sambuc namespace PR12092 { 198f4a2713aSLionel Sambuc 199f4a2713aSLionel Sambuc struct S { 200f4a2713aSLionel Sambuc S(const char*); 201f4a2713aSLionel Sambuc }; 202f4a2713aSLionel Sambuc struct V { 203f4a2713aSLionel Sambuc template<typename T> V(T, T); 204f4a2713aSLionel Sambuc void f(std::initializer_list<S>); 205f4a2713aSLionel Sambuc void f(const V &); 206f4a2713aSLionel Sambuc }; 207f4a2713aSLionel Sambuc g()208f4a2713aSLionel Sambuc void g() { 209f4a2713aSLionel Sambuc extern V s; 210f4a2713aSLionel Sambuc s.f({"foo", "bar"}); 211f4a2713aSLionel Sambuc } 212f4a2713aSLionel Sambuc 213f4a2713aSLionel Sambuc } 214f4a2713aSLionel Sambuc 215f4a2713aSLionel Sambuc namespace PR12117 { 216f4a2713aSLionel Sambuc struct A { A(int); }; 217f4a2713aSLionel Sambuc struct B { B(A); } b{{0}}; 218f4a2713aSLionel Sambuc struct C { C(int); } c{0}; 219f4a2713aSLionel Sambuc } 220f4a2713aSLionel Sambuc 221f4a2713aSLionel Sambuc namespace PR12167 { 222f4a2713aSLionel Sambuc template<int N> struct string {}; 223f4a2713aSLionel Sambuc 224f4a2713aSLionel Sambuc struct X { 225f4a2713aSLionel Sambuc X(const char v); 226f4a2713aSLionel Sambuc template<typename T> bool operator()(T) const; 227f4a2713aSLionel Sambuc }; 228f4a2713aSLionel Sambuc g(const string<N> & s,Comparator cmp)229f4a2713aSLionel Sambuc template<int N, class Comparator> bool g(const string<N>& s, Comparator cmp) { 230f4a2713aSLionel Sambuc return cmp(s); 231f4a2713aSLionel Sambuc } f(const string<N> & s)232f4a2713aSLionel Sambuc template<int N> bool f(const string<N> &s) { 233f4a2713aSLionel Sambuc return g(s, X{'x'}); 234f4a2713aSLionel Sambuc } 235f4a2713aSLionel Sambuc 236f4a2713aSLionel Sambuc bool s = f(string<1>()); 237f4a2713aSLionel Sambuc } 238f4a2713aSLionel Sambuc 239f4a2713aSLionel Sambuc namespace PR12257_PR12241 { 240f4a2713aSLionel Sambuc struct command_pair 241f4a2713aSLionel Sambuc { 242f4a2713aSLionel Sambuc command_pair(int, int); 243f4a2713aSLionel Sambuc }; 244f4a2713aSLionel Sambuc 245f4a2713aSLionel Sambuc struct command_map 246f4a2713aSLionel Sambuc { 247f4a2713aSLionel Sambuc command_map(std::initializer_list<command_pair>); 248f4a2713aSLionel Sambuc }; 249f4a2713aSLionel Sambuc 250f4a2713aSLionel Sambuc struct generator_pair 251f4a2713aSLionel Sambuc { 252f4a2713aSLionel Sambuc generator_pair(const command_map); 253f4a2713aSLionel Sambuc }; 254f4a2713aSLionel Sambuc 255f4a2713aSLionel Sambuc // 5 levels: init list, gen_pair, command_map, init list, command_pair 256f4a2713aSLionel Sambuc const std::initializer_list<generator_pair> x = {{{{{3, 4}}}}}; 257f4a2713aSLionel Sambuc 258f4a2713aSLionel Sambuc // 4 levels: init list, gen_pair, command_map via init list, command_pair 259f4a2713aSLionel Sambuc const std::initializer_list<generator_pair> y = {{{{1, 2}}}}; 260f4a2713aSLionel Sambuc } 261f4a2713aSLionel Sambuc 262f4a2713aSLionel Sambuc namespace PR12120 { 263f4a2713aSLionel Sambuc struct A { explicit A(int); A(float); }; // expected-note {{declared here}} 264f4a2713aSLionel Sambuc A a = { 0 }; // expected-error {{constructor is explicit}} 265f4a2713aSLionel Sambuc 266f4a2713aSLionel Sambuc struct B { explicit B(short); B(long); }; // expected-note 2 {{candidate}} 267f4a2713aSLionel Sambuc B b = { 0 }; // expected-error {{ambiguous}} 268f4a2713aSLionel Sambuc } 269f4a2713aSLionel Sambuc 270f4a2713aSLionel Sambuc namespace PR12498 { 271f4a2713aSLionel Sambuc class ArrayRef; // expected-note{{forward declaration}} 272f4a2713aSLionel Sambuc 273f4a2713aSLionel Sambuc struct C { 274f4a2713aSLionel Sambuc void foo(const ArrayRef&); // expected-note{{passing argument to parameter here}} 275f4a2713aSLionel Sambuc }; 276f4a2713aSLionel Sambuc bar(C * c)277f4a2713aSLionel Sambuc static void bar(C* c) 278f4a2713aSLionel Sambuc { 279f4a2713aSLionel Sambuc c->foo({ nullptr, 1 }); // expected-error{{initialization of incomplete type 'const PR12498::ArrayRef'}} 280f4a2713aSLionel Sambuc } 281f4a2713aSLionel Sambuc } 282f4a2713aSLionel Sambuc 283f4a2713aSLionel Sambuc namespace explicit_default { 284f4a2713aSLionel Sambuc struct A { 285f4a2713aSLionel Sambuc explicit A(); // expected-note{{here}} 286f4a2713aSLionel Sambuc }; 287f4a2713aSLionel Sambuc A a {}; // ok 288f4a2713aSLionel Sambuc // This is copy-list-initialization, and we choose an explicit constructor 289f4a2713aSLionel Sambuc // (even though we do so via value-initialization), so the initialization is 290f4a2713aSLionel Sambuc // ill-formed. 291f4a2713aSLionel Sambuc A b = {}; // expected-error{{chosen constructor is explicit}} 292f4a2713aSLionel Sambuc } 293f4a2713aSLionel Sambuc 294f4a2713aSLionel Sambuc namespace init_list_default { 295f4a2713aSLionel Sambuc struct A { 296f4a2713aSLionel Sambuc A(std::initializer_list<int>); 297f4a2713aSLionel Sambuc }; 298f4a2713aSLionel Sambuc A a {}; // calls initializer list constructor 299f4a2713aSLionel Sambuc 300f4a2713aSLionel Sambuc struct B { 301f4a2713aSLionel Sambuc B(); 302f4a2713aSLionel Sambuc B(std::initializer_list<int>) = delete; 303f4a2713aSLionel Sambuc }; 304f4a2713aSLionel Sambuc B b {}; // calls default constructor 305f4a2713aSLionel Sambuc } 306f4a2713aSLionel Sambuc 307f4a2713aSLionel Sambuc // PR13470, <rdar://problem/11974632> 308f4a2713aSLionel Sambuc namespace PR13470 { 309f4a2713aSLionel Sambuc struct W { 310f4a2713aSLionel Sambuc explicit W(int); // expected-note {{here}} 311f4a2713aSLionel Sambuc }; 312f4a2713aSLionel Sambuc 313f4a2713aSLionel Sambuc struct X { 314f4a2713aSLionel Sambuc X(const X&) = delete; // expected-note 3 {{here}} 315f4a2713aSLionel Sambuc X(int); 316f4a2713aSLionel Sambuc }; 317f4a2713aSLionel Sambuc call(Fn f)318f4a2713aSLionel Sambuc template<typename T, typename Fn> void call(Fn f) { 319f4a2713aSLionel Sambuc f({1}); // expected-error {{constructor is explicit}} 320f4a2713aSLionel Sambuc f(T{1}); // expected-error {{call to deleted constructor}} 321f4a2713aSLionel Sambuc } 322f4a2713aSLionel Sambuc 323f4a2713aSLionel Sambuc void ref_w(const W &); // expected-note 2 {{not viable}} call_ref_w()324f4a2713aSLionel Sambuc void call_ref_w() { 325f4a2713aSLionel Sambuc ref_w({1}); // expected-error {{no matching function}} 326f4a2713aSLionel Sambuc ref_w(W{1}); 327f4a2713aSLionel Sambuc call<W>(ref_w); // expected-note {{instantiation of}} 328f4a2713aSLionel Sambuc } 329f4a2713aSLionel Sambuc 330f4a2713aSLionel Sambuc void ref_x(const X &); call_ref_x()331f4a2713aSLionel Sambuc void call_ref_x() { 332f4a2713aSLionel Sambuc ref_x({1}); 333f4a2713aSLionel Sambuc ref_x(X{1}); 334f4a2713aSLionel Sambuc call<X>(ref_x); // ok 335f4a2713aSLionel Sambuc } 336f4a2713aSLionel Sambuc 337f4a2713aSLionel Sambuc void val_x(X); // expected-note 2 {{parameter}} call_val_x()338f4a2713aSLionel Sambuc void call_val_x() { 339f4a2713aSLionel Sambuc val_x({1}); 340f4a2713aSLionel Sambuc val_x(X{1}); // expected-error {{call to deleted constructor}} 341f4a2713aSLionel Sambuc call<X>(val_x); // expected-note {{instantiation of}} 342f4a2713aSLionel Sambuc } 343f4a2713aSLionel Sambuc 344f4a2713aSLionel Sambuc template<typename T> 345f4a2713aSLionel Sambuc struct Y { 346f4a2713aSLionel Sambuc X x{1}; fPR13470::Y347f4a2713aSLionel Sambuc void f() { X x{1}; } hPR13470::Y348f4a2713aSLionel Sambuc void h() { 349f4a2713aSLionel Sambuc ref_w({1}); // expected-error {{no matching function}} 350f4a2713aSLionel Sambuc ref_w(W{1}); 351f4a2713aSLionel Sambuc ref_x({1}); 352f4a2713aSLionel Sambuc ref_x(X{1}); 353f4a2713aSLionel Sambuc val_x({1}); 354f4a2713aSLionel Sambuc val_x(X{1}); // expected-error {{call to deleted constructor}} 355f4a2713aSLionel Sambuc } YPR13470::Y356f4a2713aSLionel Sambuc Y() {} YPR13470::Y357f4a2713aSLionel Sambuc Y(int) : x{1} {} 358f4a2713aSLionel Sambuc }; 359f4a2713aSLionel Sambuc 360f4a2713aSLionel Sambuc Y<int> yi; 361f4a2713aSLionel Sambuc Y<int> yi2(0); g()362f4a2713aSLionel Sambuc void g() { 363f4a2713aSLionel Sambuc yi.f(); 364f4a2713aSLionel Sambuc yi.h(); // ok, all diagnostics produced in template definition 365f4a2713aSLionel Sambuc } 366f4a2713aSLionel Sambuc } 367*0a6a1f1dSLionel Sambuc 368*0a6a1f1dSLionel Sambuc namespace PR19729 { 369*0a6a1f1dSLionel Sambuc struct A { 370*0a6a1f1dSLionel Sambuc A(int); 371*0a6a1f1dSLionel Sambuc A(const A&) = delete; 372*0a6a1f1dSLionel Sambuc }; 373*0a6a1f1dSLionel Sambuc struct B { 374*0a6a1f1dSLionel Sambuc void *operator new(std::size_t, A); 375*0a6a1f1dSLionel Sambuc }; 376*0a6a1f1dSLionel Sambuc B *p = new ({123}) B; 377*0a6a1f1dSLionel Sambuc } 378*0a6a1f1dSLionel Sambuc 379*0a6a1f1dSLionel Sambuc namespace PR11410 { 380*0a6a1f1dSLionel Sambuc struct A { 381*0a6a1f1dSLionel Sambuc A() = delete; // expected-note 2{{deleted here}} 382*0a6a1f1dSLionel Sambuc A(int); 383*0a6a1f1dSLionel Sambuc }; 384*0a6a1f1dSLionel Sambuc 385*0a6a1f1dSLionel Sambuc A a[3] = { 386*0a6a1f1dSLionel Sambuc {1}, {2} 387*0a6a1f1dSLionel Sambuc }; // expected-error {{call to deleted constructor}} \ 388*0a6a1f1dSLionel Sambuc expected-note {{in implicit initialization of array element 2 with omitted initializer}} 389*0a6a1f1dSLionel Sambuc 390*0a6a1f1dSLionel Sambuc struct B { 391*0a6a1f1dSLionel Sambuc A a; // expected-note {{in implicit initialization of field 'a'}} 392*0a6a1f1dSLionel Sambuc } b = { 393*0a6a1f1dSLionel Sambuc }; // expected-error {{call to deleted constructor}} 394*0a6a1f1dSLionel Sambuc 395*0a6a1f1dSLionel Sambuc struct C { 396*0a6a1f1dSLionel Sambuc C(int = 0); // expected-note 2{{candidate}} 397*0a6a1f1dSLionel Sambuc C(float = 0); // expected-note 2{{candidate}} 398*0a6a1f1dSLionel Sambuc }; 399*0a6a1f1dSLionel Sambuc C c[3] = { 400*0a6a1f1dSLionel Sambuc 0, 1 401*0a6a1f1dSLionel Sambuc }; // expected-error {{ambiguous}} expected-note {{in implicit initialization of array element 2}} 402*0a6a1f1dSLionel Sambuc C c2[3] = { 403*0a6a1f1dSLionel Sambuc [0] = 1, [2] = 3 404*0a6a1f1dSLionel Sambuc }; // expected-error {{ambiguous}} expected-note {{in implicit initialization of array element 1}} 405*0a6a1f1dSLionel Sambuc } 406