]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/g++.dg/cpp0x/range-for15.C
PR c++/92590 - wrong handling of inherited default ctor.
[gcc.git] / gcc / testsuite / g++.dg / cpp0x / range-for15.C
1 // Test for range-based for loop with templates
2 // and begin/end as member (non-)virtual functions
3
4 // { dg-do run { target c++11 } }
5
6 unsigned int g;
7
8 struct A
9 {
10 virtual int *begin()
11 {
12 g |= 1;
13 return 0;
14 }
15 int *end()
16 {
17 g |= 2;
18 return 0;
19 }
20 };
21
22 struct B : A
23 {
24 virtual int *begin()
25 {
26 g |= 4;
27 return 0;
28 }
29 int *end()
30 {
31 g |= 8;
32 return 0;
33 }
34 };
35
36 extern "C" void abort(void);
37
38 int main ()
39 {
40 A a;
41 B b;
42 A &aa = b;
43
44 g = 0;
45 for (int x : a);
46 if (g != (1 | 2))
47 abort();
48
49 g = 0;
50 for (int x : b);
51 if (g != (4 | 8))
52 abort();
53
54 g = 0;
55 for (int x : aa);
56 if (g != (4 | 2))
57 abort();
58 }
This page took 0.041726 seconds and 5 git commands to generate.