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