1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2 3// Verify that using an initializer list for a non-aggregate looks for 4// constructors.. 5// Note that due to a (likely) standard bug, this is technically an aggregate, 6// but we do not treat it as one. 7struct NonAggr1 { // expected-note 2 {{candidate constructor}} 8 NonAggr1(int, int) { } // expected-note {{candidate constructor}} 9 10 int m; 11}; 12 13struct Base { }; 14struct NonAggr2 : public Base { // expected-note 3 {{candidate constructor}} 15 int m; 16}; 17 18class NonAggr3 { // expected-note 3 {{candidate constructor}} 19 int m; 20}; 21 22struct NonAggr4 { // expected-note 3 {{candidate constructor}} 23 int m; 24 virtual void f(); 25}; 26 27NonAggr1 na1 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr1'}} 28NonAggr2 na2 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr2'}} 29NonAggr3 na3 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr3'}} 30NonAggr4 na4 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr4'}} 31 32// PR5817 33typedef int type[][2]; 34const type foo = {0}; 35 36// Vector initialization. 37typedef short __v4hi __attribute__ ((__vector_size__ (8))); 38__v4hi v1 = { (void *)1, 2, 3 }; // expected-error {{cannot initialize a vector element of type 'short' with an rvalue of type 'void *'}} 39 40// Array initialization. 41int a[] = { (void *)1 }; // expected-error {{cannot initialize an array element of type 'int' with an rvalue of type 'void *'}} 42 43// Struct initialization. 44struct S { int a; } s = { (void *)1 }; // expected-error {{cannot initialize a member subobject of type 'int' with an rvalue of type 'void *'}} 45 46// Check that we're copy-initializing the structs. 47struct A { 48 A(); 49 A(int); 50 ~A(); 51 52 A(const A&) = delete; // expected-note 2 {{'A' has been explicitly marked deleted here}} 53}; 54 55struct B { 56 A a; 57}; 58 59struct C { 60 const A& a; 61}; 62 63void f() { 64 A as1[1] = { }; 65 A as2[1] = { 1 }; // expected-error {{copying array element of type 'A' invokes deleted constructor}} 66 67 B b1 = { }; 68 B b2 = { 1 }; // expected-error {{copying member subobject of type 'A' invokes deleted constructor}} 69 70 C c1 = { 1 }; 71} 72 73class Agg { 74public: 75 int i, j; 76}; 77 78class AggAgg { 79public: 80 Agg agg1; 81 Agg agg2; 82}; 83 84AggAgg aggagg = { 1, 2, 3, 4 }; 85