repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp0x
/
ref-qual19.C
blob
50f92977c49d2a44ecb61f0c0936c5c75c903166
1
// PR c++/87109
2
// { dg-do run { target c++11 } }
3
4
#include <utility>
5
6
struct C { int i; };
7
struct D { int i; };
8
9
struct A {
10
int j;
11
operator C() & { return { 1 }; }
12
operator C() && { return { 2 }; }
13
};
14
15
struct B : public A {
16
operator D() & { return { 3 }; }
17
operator D() && { return { 4 }; }
18
};
19
20
C
21
f (A a)
22
{
23
return a;
24
}
25
26
C
27
f2 (A a)
28
{
29
return std::move (a);
30
}
31
32
C
33
f3 ()
34
{
35
A a;
36
return a;
37
}
38
39
C
40
f4 ()
41
{
42
A a;
43
return std::move (a);
44
}
45
46
C
47
f5 ()
48
{
49
return A();
50
}
51
52
D
53
f6 (B b)
54
{
55
return b;
56
}
57
58
D
59
f7 (B b)
60
{
61
return std::move (b);
62
}
63
64
D
65
f8 ()
66
{
67
B b;
68
return b;
69
}
70
71
D
72
f9 ()
73
{
74
B b;
75
return std::move (b);
76
}
77
78
D
79
f10 ()
80
{
81
return B();
82
}
83
84
int
85
main ()
86
{
87
C c1 = f (A());
88
if (c1.i != 2)
89
__builtin_abort ();
90
C c2 = f2 (A());
91
if (c2.i != 2)
92
__builtin_abort ();
93
C c3 = f3 ();
94
if (c3.i != 2)
95
__builtin_abort ();
96
C c4 = f4 ();
97
if (c4.i != 2)
98
__builtin_abort ();
99
C c5 = f5 ();
100
if (c5.i != 2)
101
__builtin_abort ();
102
D c6 = f6 (B());
103
if (c6.i != 4)
104
__builtin_abort ();
105
D c7 = f7 (B());
106
if (c7.i != 4)
107
__builtin_abort ();
108
D c8 = f8 ();
109
if (c8.i != 4)
110
__builtin_abort ();
111
D c9 = f9 ();
112
if (c9.i != 4)
113
__builtin_abort ();
114
D c10 = f10 ();
115
if (c10.i != 4)
116
__builtin_abort ();
117
}