blob: 379f9655dd5ac4e48c4106723b7702cb64fd80d5 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#include <mozilla/RefPtr.h>
// we can't include nsCOMPtr.h here, so let's redefine a basic version
template<typename T>
struct nsCOMPtr {
nsCOMPtr() = default;
template<typename U>
MOZ_IMPLICIT nsCOMPtr(already_AddRefed<U>&& aSrc);
template<typename U>
nsCOMPtr& operator=(already_AddRefed<U>&& aSrc);
};
using namespace mozilla;
struct RefCountedBase {
void AddRef();
void Release();
void method_test();
};
struct RefCountedDerived : RefCountedBase {};
struct RefCountedBaseHolder {
RefPtr<RefCountedBase> GetRefCountedBase() const {
return mRefCountedBase;
}
private:
RefPtr<RefCountedBase> mRefCountedBase = MakeRefPtr<RefCountedBase>();
};
void test_assign_same_type() {
RefPtr<RefCountedBase> a = MakeRefPtr<RefCountedBase>();
RefPtr<RefCountedBase> b;
b = a.forget(); // expected-warning {{non-standard move assignment}}
}
void test_assign_implicit_cast() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
RefPtr<RefCountedBase> b;
b = a.forget(); // expected-warning {{non-standard move assignment}}
}
void test_assign_different_template() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
nsCOMPtr<RefCountedBase> b;
b = a.forget(); // expected-warning {{non-standard move assignment}}
}
void test_construct_different_template() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
nsCOMPtr<RefCountedBase> b = a.forget(); // expected-warning {{non-standard move construction}}
}
void test_assign_already_addrefed() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
already_AddRefed<RefCountedDerived> b;
b = a.forget();
}
void test_construct_already_addrefed() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
already_AddRefed<RefCountedDerived> b = a.forget();
}
void test_construct_same_type() {
RefPtr<RefCountedBase> a = MakeRefPtr<RefCountedBase>();
RefPtr<RefCountedBase> b = a.forget(); // expected-warning {{non-standard move construction}}
}
void test_construct_implicit_cast() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
RefPtr<RefCountedBase> b = a.forget(); // expected-warning {{non-standard move construction}}
}
void test_construct_brace_same_type() {
RefPtr<RefCountedBase> a = MakeRefPtr<RefCountedBase>();
auto b = RefPtr<RefCountedBase>{a.forget()}; // expected-warning {{non-standard move construction}}
}
void test_construct_brace_implicit_cast() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
auto b = RefPtr<RefCountedBase>{a.forget()}; // expected-warning {{non-standard move construction}}
}
void test_construct_function_style_same_type() {
RefPtr<RefCountedBase> a = MakeRefPtr<RefCountedBase>();
auto b = RefPtr<RefCountedBase>(a.forget()); // expected-warning {{non-standard move construction}}
}
void test_construct_function_style_implicit_cast() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
auto b = RefPtr<RefCountedBase>(a.forget()); // expected-warning {{non-standard move construction}}
}
void test_construct_result_type() {
RefPtr<RefCountedBase> a = MakeRefPtr<RefCountedBase>();
already_AddRefed<RefCountedBase> b = a.forget();
}
void test_construct_implicitly_cast_result_type() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
already_AddRefed<RefCountedBase> b = a.forget();
}
void foo(already_AddRefed<RefCountedBase>&& aArg);
void test_call_with_result_type() {
RefPtr<RefCountedBase> a = MakeRefPtr<RefCountedBase>();
foo(a.forget());
}
void test_call_with_implicitly_cast_result_type() {
RefPtr<RefCountedDerived> a = MakeRefPtr<RefCountedDerived>();
foo(a.forget());
}
|