repo.or.cz
/
gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Daily bump.
[gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp0x
/
range-for15.C
blob
5dd442dd1d5534b0fda386123c509c7bdcc43ea5
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
}