blob: 9c97ad5faf08d32d6436bc178f2c2c446483edc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Test for errors in range-based for loops
// { dg-do compile }
// { dg-options "-std=c++0x" }
struct container
{
};
int *begin(const container &c)
{
return 0;
}
int end(const container &c) //Ops! wrong type
{
return 0;
}
struct Implicit
{
Implicit(int x)
{}
};
struct Explicit
{
explicit Explicit(int x)
{}
};
void test1()
{
container c;
for (int x : c) // { dg-error "inconsistent|conversion" }
;
int a[2] = {1,2};
for (Implicit x : a)
;
for (Explicit x : a) // { dg-error "conversion" }
;
for (const Implicit &x : a)
;
for (Implicit &&x : a)
;
//Check the correct scopes
int i;
for (int i : a)
{
int i;
}
}
|