OSDN Git Service

PR c++/36628
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / initlist6.C
1 // Test for initlist lifetime
2 // { dg-options "-std=c++0x" }
3 // { dg-do run }
4
5 #include <initializer_list>
6
7 int c;
8
9 struct A
10 {
11   A(int,int) { ++c; }
12   ~A() { --c; }
13 };
14
15 void f (std::initializer_list<A> l) { }
16
17 int main()
18 {
19   f({ {1,2}, {3,4} });
20   if (c != 0)
21     return 1;
22
23   {
24     std::initializer_list<A> l { {1,2}, {3,4} };
25     if (c != 2)
26       return 2;
27   }
28   if (c != 0)
29     return 3;
30 }