OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [range-for15.C] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// Test for range-based for loop with templates
2
// and begin/end as member (non-)virtual functions
3
 
4
// { dg-do run }
5
// { dg-options "-std=c++0x" }
6
 
7
unsigned int g;
8
 
9
struct A
10
{
11
    virtual int *begin()
12
    {
13
        g |= 1;
14
        return 0;
15
    }
16
    int *end()
17
    {
18
        g |= 2;
19
        return 0;
20
    }
21
};
22
 
23
struct B : A
24
{
25
    virtual int *begin()
26
    {
27
        g |= 4;
28
        return 0;
29
    }
30
    int *end()
31
    {
32
        g |= 8;
33
        return 0;
34
    }
35
};
36
 
37
extern "C" void abort(void);
38
 
39
int main ()
40
{
41
    A a;
42
    B b;
43
    A &aa = b;
44
 
45
    g = 0;
46
    for (int x : a);
47
    if (g != (1 | 2))
48
        abort();
49
 
50
    g = 0;
51
    for (int x : b);
52
    if (g != (4 | 8))
53
        abort();
54
 
55
    g = 0;
56
    for (int x : aa);
57
    if (g != (4 | 2))
58
        abort();
59
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.