blob: 7878a4cde5aeec55531d1b4e9880ed6baf47bd2f (
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
#define MOZ_MUST_USE_TYPE __attribute__((annotate("moz_must_use_type")))
struct Temporary { ~Temporary(); };
class MOZ_MUST_USE_TYPE MustUse {};
class MayUse {};
MustUse producesMustUse();
MustUse *producesMustUsePointer();
MustUse &producesMustUseRef();
MustUse producesMustUse(const Temporary& t);
MustUse *producesMustUsePointer(const Temporary& t);
MustUse &producesMustUseRef(const Temporary& t);
MayUse producesMayUse();
MayUse *producesMayUsePointer();
MayUse &producesMayUseRef();
void use(MustUse*);
void use(MustUse&);
void use(MustUse&&);
void use(MayUse*);
void use(MayUse&);
void use(MayUse&&);
void use(bool);
void foo() {
MustUse u;
producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMustUsePointer();
producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMayUse();
producesMayUsePointer();
producesMayUseRef();
u = producesMustUse();
u = producesMustUse(Temporary());
{
producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMustUsePointer();
producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMayUse();
producesMayUsePointer();
producesMayUseRef();
u = producesMustUse();
u = producesMustUse(Temporary());
}
if (true) {
producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMustUsePointer();
producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMayUse();
producesMayUsePointer();
producesMayUseRef();
u = producesMustUse();
u = producesMustUse(Temporary());
} else {
producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMustUsePointer();
producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMayUse();
producesMayUsePointer();
producesMayUseRef();
u = producesMustUse();
u = producesMustUse(Temporary());
}
if(true) producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
else producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
if(true) producesMustUsePointer();
else producesMustUsePointer();
if(true) producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
else producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
if(true) producesMayUse();
else producesMayUse();
if(true) producesMayUsePointer();
else producesMayUsePointer();
if(true) producesMayUseRef();
else producesMayUseRef();
if(true) u = producesMustUse();
else u = producesMustUse();
if(true) u = producesMustUse(Temporary());
else u = producesMustUse(Temporary());
while (true) producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
while (true) producesMustUsePointer();
while (true) producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
while (true) producesMayUse();
while (true) producesMayUsePointer();
while (true) producesMayUseRef();
while (true) u = producesMustUse();
while (true) u = producesMustUse(Temporary());
do producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
while (true);
do producesMustUsePointer();
while (true);
do producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
while (true);
do producesMayUse();
while (true);
do producesMayUsePointer();
while (true);
do producesMayUseRef();
while (true);
do u = producesMustUse();
while (true);
do u = producesMustUse(Temporary());
while (true);
for (;;) producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
for (;;) producesMustUsePointer();
for (;;) producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
for (;;) producesMayUse();
for (;;) producesMayUsePointer();
for (;;) producesMayUseRef();
for (;;) u = producesMustUse();
for (;;) u = producesMustUse(Temporary());
for (producesMustUse();;); // expected-error {{Unused value of must-use type 'MustUse'}}
for (producesMustUsePointer();;);
for (producesMustUseRef();;); // expected-error {{Unused value of must-use type 'MustUse'}}
for (producesMayUse();;);
for (producesMayUsePointer();;);
for (producesMayUseRef();;);
for (u = producesMustUse();;);
for (u = producesMustUse(Temporary());;);
for (;;producesMustUse()); // expected-error {{Unused value of must-use type 'MustUse'}}
for (;;producesMustUsePointer());
for (;;producesMustUseRef()); // expected-error {{Unused value of must-use type 'MustUse'}}
for (;;producesMayUse());
for (;;producesMayUsePointer());
for (;;producesMayUseRef());
for (;;u = producesMustUse());
for (;;u = producesMustUse(Temporary()));
use((producesMustUse(), false)); // expected-error {{Unused value of must-use type 'MustUse'}}
use((producesMustUsePointer(), false));
use((producesMustUseRef(), false)); // expected-error {{Unused value of must-use type 'MustUse'}}
use((producesMayUse(), false));
use((producesMayUsePointer(), false));
use((producesMayUseRef(), false));
use((u = producesMustUse(), false));
use((u = producesMustUse(Temporary()), false));
switch (1) {
case 1:
producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMustUsePointer();
producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMayUse();
producesMayUsePointer();
producesMayUseRef();
u = producesMustUse();
u = producesMustUse(Temporary());
case 2:
producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
case 3:
producesMustUsePointer();
case 4:
producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
case 5:
producesMayUse();
case 6:
producesMayUsePointer();
case 7:
producesMayUseRef();
case 8:
u = producesMustUse();
case 9:
u = producesMustUse(Temporary());
default:
producesMustUse(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMustUsePointer();
producesMustUseRef(); // expected-error {{Unused value of must-use type 'MustUse'}}
producesMayUse();
producesMayUsePointer();
producesMayUseRef();
u = producesMustUse();
u = producesMustUse(Temporary());
}
use(producesMustUse());
use(producesMustUsePointer());
use(producesMustUseRef());
use(producesMayUse());
use(producesMayUsePointer());
use(producesMayUseRef());
use(u = producesMustUse());
use(u = producesMustUse(Temporary()));
MustUse a = producesMustUse();
MustUse *b = producesMustUsePointer();
MustUse &c = producesMustUseRef();
MayUse d = producesMayUse();
MayUse *e = producesMayUsePointer();
MayUse &f = producesMayUseRef();
MustUse g = u = producesMustUse();
MustUse h = u = producesMustUse(Temporary());
}
|