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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 693 jeremybenn
// Test for other range-based for loops with
2
// begin/end member functions
3
 
4
// { dg-do compile }
5
// { dg-options "-std=c++0x" }
6
 
7
//These should not be used
8
template int *begin(T &t)
9
{
10
    T::fail;
11
}
12
template int *end(T &t)
13
{
14
    T::fail;
15
}
16
 
17
//Test for defaults
18
 
19
struct default1
20
{
21
    int *begin(int x); // { dg-message "note" }
22
    int *end();
23
};
24
 
25
struct default2
26
{
27
    int *begin(int x=0);
28
    int *end();
29
};
30
 
31
struct default3
32
{
33
    template  T *begin(); // { dg-message "note" }
34
    int *end();
35
};
36
 
37
struct default4
38
{
39
    template  T *begin();
40
    int *end();
41
};
42
 
43
struct default5
44
{
45
    template  T *begin(int x=0);
46
    int *end();
47
};
48
 
49
void test1()
50
{
51
  for (int x : default1()); // { dg-error "no matching function|note" }
52
  for (int x : default2());
53
  for (int x : default3()); // { dg-error "no matching function|note" }
54
  for (int x : default4());
55
  for (int x : default5());
56
}
57
 
58
//Inheritance tests
59
 
60
struct base_begin
61
{
62
    int *begin(); // { dg-error "" }
63
};
64
 
65
struct base_end
66
{
67
    int *end();
68
};
69
 
70
struct derived1 : base_begin, base_end
71
{
72
};
73
 
74
struct base_begin2 : base_begin
75
{
76
};
77
 
78
struct derived2 : base_begin, base_end, base_begin2 // { dg-warning "" }
79
{
80
};
81
 
82
struct base_begin3 : virtual base_begin
83
{
84
};
85
 
86
struct derived3 : virtual base_begin, base_end, base_begin3
87
{
88
};
89
 
90
void test2()
91
{
92
  for (int x : derived1());
93
  for (int x : derived2()); // { dg-error "is ambiguous" }
94
  for (int x : derived3());
95
}

powered by: WebSVN 2.1.0

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