]> gcc.gnu.org Git - gcc.git/blame - gcc/testsuite/g++.dg/cpp0x/range-for13.C
PR c++/92590 - wrong handling of inherited default ctor.
[gcc.git] / gcc / testsuite / g++.dg / cpp0x / range-for13.C
CommitLineData
deb9642d
JM
1// Test for errors in range-based for loops
2// with member begin/end
3
4b2e63de 4// { dg-do compile { target c++11 } }
deb9642d 5
deb9642d
JM
6struct container1
7{
8 int *begin();
9 //no end
10};
11
12struct container2
13{
14 int *end();
15 //no begin
16};
17
18struct container3
19{
20private:
3a1351b9
PC
21 int *begin(); // { dg-message "private" }
22 int *end(); // { dg-message "private" }
deb9642d
JM
23};
24
25struct container4
26{
27 int *begin;
28 int *end;
29};
30
31struct container5
32{
33 typedef int *begin;
34 typedef int *end;
35};
36
37struct callable
38{
39 int *operator()();
40};
41
42struct container6
43{
44 callable begin;
45 callable end;
46};
47
48struct container7
49{
50 static callable begin;
51 static callable end;
52};
53
54struct container8
55{
56 static int *begin();
57 int *end();
58};
59
60struct private_callable
61{
62private:
3a1351b9 63 int *operator()(); // { dg-message "private" }
deb9642d
JM
64};
65
66struct container9
67{
68 private_callable begin;
69 private_callable end;
70};
71
72struct container10
73{
74 typedef int *(*function)();
75
76 function begin;
77 static function end;
78};
79
50531a2a
VV
80namespace N
81{
82template<typename T> int *begin(T &t)
83{
84 return 0;
85}
86template<typename T> int *end(T &t)
87{
88 return 0;
89}
90struct container11
91{
92 int *begin();
93 //no end
94};
95
96struct container12
97{
98 int *end();
99 //no begin
100};
101
102struct container13
103{
104};
105}
106
deb9642d
JM
107void test1()
108{
50531a2a
VV
109 for (int x : container1()); // { dg-error "'begin' was not declared|'end' was not declared" }
110 for (int x : container2()); // { dg-error "'begin' was not declared|'end' was not declared" }
deb9642d
JM
111 for (int x : container3()); // { dg-error "within this context" }
112 for (int x : container4()); // { dg-error "cannot be used as a function" }
113 for (int x : container5()); // { dg-error "invalid use of" }
114 for (int x : container6());
115 for (int x : container7());
116 for (int x : container8());
117 for (int x : container9()); // { dg-error "within this context" }
118 for (int x : container10());
50531a2a
VV
119 for (int x : N::container11());
120 for (int x : N::container12());
121 for (int x : N::container13());
deb9642d 122}
This page took 5.680848 seconds and 5 git commands to generate.