1 // RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
3 struct one { char c[1]; };
4 struct two { char c[2]; };
22 S s1 = { 1, 2, 3 ,4, 5, 6, 7, 8 };
23 S s2{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } };
24 S s3{ 1, 2, 3, 4, 5, 6 };
25 S s4{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } };
26 S s5{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} };
30 new S{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } };
31 new S{ 1, 2, 3, 4, 5, 6 };
32 new S{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } };
33 new S{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} };
36 void bracing_construct() {
37 (void) S{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } };
38 (void) S{ 1, 2, 3, 4, 5, 6 };
39 (void) S{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } };
40 (void) S{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} };
52 void function_call() {
62 void overloaded_call() {
66 static_assert(sizeof(overloaded({1, 2})) == sizeof(one), "bad overload");
67 static_assert(sizeof(overloaded({1, "two"})) == sizeof(two),
69 // String is not default-constructible
70 static_assert(sizeof(overloaded({1})) == sizeof(one), "bad overload");
73 struct C { int a[2]; C():a({1, 2}) { } }; // expected-error {{parenthesized initialization of a member array is a GNU extension}}
76 namespace array_explicit_conversion {
79 template<int x> struct A { int a[x]; }; // expected-error {{'a' declared as an array with a negative size}}
81 typedef A<-1> test4[];
86 (void)test4{{{1}}}; // expected-note {{in instantiation of template class 'array_explicit_conversion::A<-1>' requested here}}
90 namespace sub_constructor {
91 struct DefaultConstructor { // expected-note 2 {{not viable}}
92 DefaultConstructor(); // expected-note {{not viable}}
95 struct NoDefaultConstructor1 { // expected-note 2 {{not viable}}
96 NoDefaultConstructor1(int); // expected-note {{not viable}}
99 struct NoDefaultConstructor2 { // expected-note 4 {{not viable}}
100 NoDefaultConstructor2(int,int); // expected-note 2 {{not viable}}
105 DefaultConstructor a;
106 NoDefaultConstructor1 b;
107 NoDefaultConstructor2 c;
110 Aggr ok1 { {}, {0} , {0,0} };
111 Aggr ok2 = { {}, {0} , {0,0} };
112 Aggr too_many { {0} , {0} , {0,0} }; // expected-error {{no matching constructor for initialization}}
113 Aggr too_few { {} , {0} , {0} }; // expected-error {{no matching constructor for initialization}}
114 Aggr invalid { {} , {&ok1} , {0,0} }; // expected-error {{no matching constructor for initialization}}
115 NoDefaultConstructor2 array_ok[] = { {0,0} , {0,1} };
116 NoDefaultConstructor2 array_error[] = { {0,0} , {0} }; // expected-error {{no matching constructor for initialization}}
119 namespace multidimensional_array {
120 void g(const int (&)[2][2]) {}
121 void g(const int (&)[2][2][2]) = delete;
128 namespace array_addressof {
130 T *p = &T{1,2,3,4,5}; // expected-error {{taking the address of a temporary object of type 'array_addressof::T' (aka 'int [5]')}}
134 struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}}