gcc/testsuite/g++.dg/cpp0x/initlist105.C
raw| 1 | // PR c++/86669 |
| 2 | // { dg-do run { target c++11 } } |
| 3 | |
| 4 | #include <initializer_list> |
| 5 | |
| 6 | struct S { S (); }; |
| 7 | struct T : public S {}; |
| 8 | int cnt; |
| 9 | void foo (int) { cnt++; } |
| 10 | |
| 11 | S::S () |
| 12 | { |
| 13 | int e = 1, f = 2, g = 3, h = 4; |
| 14 | |
| 15 | for (auto k : { e, f, g, h }) |
| 16 | foo (k); |
| 17 | } |
| 18 | |
| 19 | int |
| 20 | main () |
| 21 | { |
| 22 | S s; |
| 23 | if (cnt != 4) |
| 24 | __builtin_abort (); |
| 25 | T t; |
| 26 | if (cnt != 8) |
| 27 | __builtin_abort (); |
| 28 | } |