1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 // Verify that using an initializer list for a non-aggregate looks for
5 // Note that due to a (likely) standard bug, this is technically an aggregate,
6 // but we do not treat it as one.
7 struct NonAggr1 { // expected-note 2 {{candidate constructor}}
8 NonAggr1(int, int) { } // expected-note {{candidate constructor}}
14 struct NonAggr2 : public Base { // expected-note 3 {{candidate constructor}}
18 class NonAggr3 { // expected-note 3 {{candidate constructor}}
22 struct NonAggr4 { // expected-note 3 {{candidate constructor}}
27 NonAggr1 na1 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr1'}}
28 NonAggr2 na2 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr2'}}
29 NonAggr3 na3 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr3'}}
30 NonAggr4 na4 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr4'}}
33 typedef int type[][2];
36 // Vector initialization.
37 typedef 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 *'}}
40 // Array initialization.
41 int a[] = { (void *)1 }; // expected-error {{cannot initialize an array element of type 'int' with an rvalue of type 'void *'}}
43 // Struct initialization.
44 struct S { int a; } s = { (void *)1 }; // expected-error {{cannot initialize a member subobject of type 'int' with an rvalue of type 'void *'}}
46 // Check that we're copy-initializing the structs.
52 A(const A&) = delete; // expected-note 2 {{function has been explicitly marked deleted here}}
65 A as2[1] = { 1 }; // expected-error {{copying array element of type 'A' invokes deleted constructor}}
68 B b2 = { 1 }; // expected-error {{copying member subobject of type 'A' invokes deleted constructor}}
84 AggAgg aggagg = { 1, 2, 3, 4 };