URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [range-for15.C] - Rev 783
Compare with Previous | Blame | View Log
// Test for range-based for loop with templates
// and begin/end as member (non-)virtual functions
// { dg-do run }
// { dg-options "-std=c++0x" }
unsigned int g;
struct A
{
virtual int *begin()
{
g |= 1;
return 0;
}
int *end()
{
g |= 2;
return 0;
}
};
struct B : A
{
virtual int *begin()
{
g |= 4;
return 0;
}
int *end()
{
g |= 8;
return 0;
}
};
extern "C" void abort(void);
int main ()
{
A a;
B b;
A &aa = b;
g = 0;
for (int x : a);
if (g != (1 | 2))
abort();
g = 0;
for (int x : b);
if (g != (4 | 8))
abort();
g = 0;
for (int x : aa);
if (g != (4 | 2))
abort();
}