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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [range-for13.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 errors in range-based for loops
2
// with member begin/end
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
struct container1
18
{
19
    int *begin();
20
    //no end
21
};
22
 
23
struct container2
24
{
25
    int *end();
26
    //no begin
27
};
28
 
29
struct container3
30
{
31
private:
32
    int *begin(); // { dg-error "is private" }
33
    int *end(); // { dg-error "is private" }
34
};
35
 
36
struct container4
37
{
38
    int *begin;
39
    int *end;
40
};
41
 
42
struct container5
43
{
44
    typedef int *begin;
45
    typedef int *end;
46
};
47
 
48
struct callable
49
{
50
    int *operator()();
51
};
52
 
53
struct container6
54
{
55
    callable begin;
56
    callable end;
57
};
58
 
59
struct container7
60
{
61
    static callable begin;
62
    static callable end;
63
};
64
 
65
struct container8
66
{
67
    static int *begin();
68
    int *end();
69
};
70
 
71
struct private_callable
72
{
73
private:
74
    int *operator()(); // { dg-error "is private" }
75
};
76
 
77
struct container9
78
{
79
    private_callable begin;
80
    private_callable end;
81
};
82
 
83
struct container10
84
{
85
    typedef int *(*function)();
86
 
87
    function begin;
88
    static function end;
89
};
90
 
91
void test1()
92
{
93
  for (int x : container1()); // { dg-error "member but not" }
94
  for (int x : container2()); // { dg-error "member but not" }
95
  for (int x : container3()); // { dg-error "within this context" }
96
  for (int x : container4()); // { dg-error "cannot be used as a function" }
97
  for (int x : container5()); // { dg-error "invalid use of" }
98
  for (int x : container6());
99
  for (int x : container7());
100
  for (int x : container8());
101
  for (int x : container9()); // { dg-error "within this context" }
102
  for (int x : container10());
103
}

powered by: WebSVN 2.1.0

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