Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/initlist117.C

raw
1 // PR c++/66139
2 // { dg-do run { target c++11 } }
3
4 #include <initializer_list>
5
6 int c, d;
7
8 struct a
9 {
10 a (int i) { if (i) throw i; c++; }
11 ~a () { d++; }
12 };
13
14 void check (void (*f) ())
15 {
16 try
17 {
18 c = d = 0;
19 f ();
20 }
21 catch (int)
22 {
23 if (c != 1 || d != 1)
24 __builtin_abort ();
25 return;
26 }
27 __builtin_abort ();
28 }
29
30 int main ()
31 {
32 struct s { a x, y; };
33 check ([] { s t { 0, 1 }; });
34 check ([] { s { 0, 1 }; });
35 check ([] { a t[2] { 0, 1 }; });
36 using array = a[2];
37 check ([] { array { 0, 1 }; });
38 check ([] { std::initializer_list <a> t { 0, 1 }; });
39 check ([] { std::initializer_list <a> { 0, 1 }; });
40 }