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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [reference_collapsing.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
// I, Howard Hinnant, hereby place this code in the public domain.
2
 
3
// Test the reference collapsing rules.  Note that there are recent differences
4
//    for how cv-qualifications are applied to reference types. 7.1.3, 14.3.1
5
 
6
// { dg-do compile }
7
// { dg-options "-std=c++0x" }
8
 
9
template  struct sa;
10
template <> struct sa {};
11
 
12
template 
13
struct integral_constant
14
{
15
        static const T                  value = v;
16
        typedef T                       value_type;
17
        typedef integral_constant type;
18
};
19
 
20
typedef integral_constant  true_type;
21
typedef integral_constant false_type;
22
 
23
template  struct is_lvalue_reference     : public integral_constant {};
24
template  struct is_lvalue_reference : public integral_constant {};
25
 
26
template  struct is_rvalue_reference      : public integral_constant {};
27
template  struct is_rvalue_reference : public integral_constant {};
28
 
29
template  struct remove_reference      {typedef T type;};
30
template  struct remove_reference  {typedef T type;};
31
template  struct remove_reference {typedef T type;};
32
 
33
template  struct is_const          : public integral_constant {};
34
template  struct is_const : public integral_constant {};
35
 
36
template  struct is_volatile             : public integral_constant {};
37
template  struct is_volatile : public integral_constant {};
38
 
39
struct A {};
40
 
41
typedef A& Alref;
42
typedef const A& cAlref;
43
typedef volatile A& vAlref;
44
typedef const volatile A& cvAlref;
45
 
46
typedef A&& Arref;
47
typedef const A&& cArref;
48
typedef volatile A&& vArref;
49
typedef const volatile A&& cvArref;
50
 
51
template 
52
void test()
53
{
54
    sa::value == is_lvalue_ref> t1;
55
    sa::value == is_rvalue_ref> t2;
56
    sa::type>::value == s_const>    t3;
57
    sa::type>::value == s_volatile> t4;
58
    sa::type>::value == s_const   > t5;
59
    sa::type>::value == s_volatile> t6;
60
}
61
 
62
int main()
63
{
64
    // sanity check
65
    test<               A&,   true, false, false, false>();
66
    test();
67
    test<      volatile A&,   true, false, false,  true>();
68
    test();
69
    test<               A&&, false,  true, false, false>();
70
    test();
71
    test<      volatile A&&, false,  true, false,  true>();
72
    test();
73
 
74
// lvalue reference test
75
 
76
    // Alref
77
    test<               Alref&,  true, false, false, false>();
78
    test();
79
    test<      volatile Alref&,  true, false, false, false>();
80
    test();
81
 
82
    // cAlref
83
    test<               cAlref&,  true, false,  true, false>();
84
    test();
85
    test<      volatile cAlref&,  true, false,  true, false>();
86
    test();
87
 
88
    // vAlref
89
    test<               vAlref&,  true, false, false,  true>();
90
    test();
91
    test<      volatile vAlref&,  true, false, false,  true>();
92
    test();
93
 
94
    // cvAlref
95
    test<               cvAlref&,  true, false,  true,  true>();
96
    test();
97
    test<      volatile cvAlref&,  true, false,  true,  true>();
98
    test();
99
 
100
    // Arref
101
    test<               Arref&,  true, false, false, false>();
102
    test();
103
    test<      volatile Arref&,  true, false, false, false>();
104
    test();
105
 
106
    // cArref
107
    test<               cArref&,  true, false,  true, false>();
108
    test();
109
    test<      volatile cArref&,  true, false,  true, false>();
110
    test();
111
 
112
    // vArref
113
    test<               vArref&,  true, false, false,  true>();
114
    test();
115
    test<      volatile vArref&,  true, false, false,  true>();
116
    test();
117
 
118
    // vArref
119
    test<               cvArref&,  true, false,  true,  true>();
120
    test();
121
    test<      volatile cvArref&,  true, false,  true,  true>();
122
    test();
123
 
124
// rvalue reference test
125
 
126
    // Alref
127
    test<               Alref&&,  true, false, false, false>();
128
    test();
129
    test<      volatile Alref&&,  true, false, false, false>();
130
    test();
131
 
132
    // cAlref
133
    test<               cAlref&&,  true, false,  true, false>();
134
    test();
135
    test<      volatile cAlref&&,  true, false,  true, false>();
136
    test();
137
 
138
    // vAlref
139
    test<               vAlref&&,  true, false, false,  true>();
140
    test();
141
    test<      volatile vAlref&&,  true, false, false,  true>();
142
    test();
143
 
144
    // cvAlref
145
    test<               cvAlref&&,  true, false,  true,  true>();
146
    test();
147
    test<      volatile cvAlref&&,  true, false,  true,  true>();
148
    test();
149
 
150
    // Arref
151
    test<               Arref&&, false,  true, false, false>();
152
    test();
153
    test<      volatile Arref&&, false,  true, false, false>();
154
    test();
155
 
156
    // cArref
157
    test<               cArref&&, false,  true,  true, false>();
158
    test();
159
    test<      volatile cArref&&, false,  true,  true, false>();
160
    test();
161
 
162
    // vArref
163
    test<               vArref&&, false,  true, false,  true>();
164
    test();
165
    test<      volatile vArref&&, false,  true, false,  true>();
166
    test();
167
 
168
    // cvArref
169
    test<               cvArref&&, false,  true,  true,  true>();
170
    test();
171
    test<      volatile cvArref&&, false,  true,  true,  true>();
172
    test();
173
 
174
    return 0;
175
}

powered by: WebSVN 2.1.0

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