Skip to content

Commit 543f9e7

Browse files
authored
[clang-tidy] Improve bugprone-unused-return-value check (#66573)
Improve diagnostic message to be more straight forward, fix handling of casting to non-void and add new option AllowCastToVoid to control casting to void behavior. Closes #66570
1 parent c9e8b73 commit 543f9e7

File tree

9 files changed

+114
-82
lines changed

9 files changed

+114
-82
lines changed

clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,35 @@ UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
130130
"::std::error_condition;"
131131
"::std::errc;"
132132
"::std::expected;"
133-
"::boost::system::error_code"))) {}
133+
"::boost::system::error_code"))),
134+
AllowCastToVoid(Options.get("AllowCastToVoid", false)) {}
134135

135136
void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
136137
Options.store(Opts, "CheckedFunctions", CheckedFunctions);
137138
Options.store(Opts, "CheckedReturnTypes",
138139
utils::options::serializeStringList(CheckedReturnTypes));
140+
Options.store(Opts, "AllowCastToVoid", AllowCastToVoid);
139141
}
140142

141143
void UnusedReturnValueCheck::registerMatchers(MatchFinder *Finder) {
142144
auto FunVec = utils::options::parseStringList(CheckedFunctions);
143145

144-
auto MatchedCallExpr = expr(ignoringImplicit(ignoringParenImpCasts(
145-
callExpr(callee(functionDecl(
146-
// Don't match void overloads of checked functions.
147-
unless(returns(voidType())),
148-
anyOf(isInstantiatedFrom(hasAnyName(FunVec)),
149-
returns(hasCanonicalType(hasDeclaration(
150-
namedDecl(matchers::matchesAnyListedName(
151-
CheckedReturnTypes)))))))))
152-
.bind("match"))));
146+
auto MatchedDirectCallExpr =
147+
expr(callExpr(callee(functionDecl(
148+
// Don't match void overloads of checked functions.
149+
unless(returns(voidType())),
150+
anyOf(isInstantiatedFrom(hasAnyName(FunVec)),
151+
returns(hasCanonicalType(hasDeclaration(
152+
namedDecl(matchers::matchesAnyListedName(
153+
CheckedReturnTypes)))))))))
154+
.bind("match"));
155+
156+
auto CheckCastToVoid =
157+
AllowCastToVoid ? castExpr(unless(hasCastKind(CK_ToVoid))) : castExpr();
158+
auto MatchedCallExpr = expr(
159+
anyOf(MatchedDirectCallExpr,
160+
explicitCastExpr(unless(cxxFunctionalCastExpr()), CheckCastToVoid,
161+
hasSourceExpression(MatchedDirectCallExpr))));
153162

154163
auto UnusedInCompoundStmt =
155164
compoundStmt(forEach(MatchedCallExpr),
@@ -178,8 +187,13 @@ void UnusedReturnValueCheck::registerMatchers(MatchFinder *Finder) {
178187
void UnusedReturnValueCheck::check(const MatchFinder::MatchResult &Result) {
179188
if (const auto *Matched = Result.Nodes.getNodeAs<CallExpr>("match")) {
180189
diag(Matched->getBeginLoc(),
181-
"the value returned by this function should be used")
190+
"the value returned by this function should not be disregarded; "
191+
"neglecting it may lead to errors")
182192
<< Matched->getSourceRange();
193+
194+
if (!AllowCastToVoid)
195+
return;
196+
183197
diag(Matched->getBeginLoc(),
184198
"cast the expression to void to silence this warning",
185199
DiagnosticIDs::Note);

clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ class UnusedReturnValueCheck : public ClangTidyCheck {
2424
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
2525
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
2626
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
27+
std::optional<TraversalKind> getCheckTraversalKind() const override {
28+
return TK_IgnoreUnlessSpelledInSource;
29+
}
2730

2831
private:
2932
std::string CheckedFunctions;
3033
const std::vector<StringRef> CheckedReturnTypes;
34+
const bool AllowCastToVoid;
3135
};
3236

3337
} // namespace clang::tidy::bugprone

clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ class CERTModule : public ClangTidyModule {
328328
ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
329329
Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
330330
Opts["cert-err33-c.CheckedFunctions"] = CertErr33CCheckedFunctions;
331+
Opts["cert-err33-c.AllowCastToVoid"] = "true";
331332
Opts["cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField"] = "false";
332333
Opts["cert-str34-c.DiagnoseSignedUnsignedCharComparisons"] = "false";
333334
return Options;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ Changes in existing checks
232232
<clang-tidy/checks/bugprone/undefined-memory-manipulation>` check to support
233233
fixed-size arrays of non-trivial types.
234234

235+
- Improved :doc:`bugprone-unused-return-value
236+
<clang-tidy/checks/bugprone/unused-return-value>` check diagnostic message,
237+
added support for detection of unused results when cast to non-``void`` type.
238+
Casting to ``void`` no longer suppresses issues by default, control this
239+
behavior with the new `AllowCastToVoid` option.
240+
235241
- Improved :doc:`cppcoreguidelines-avoid-non-const-global-variables
236242
<clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables>` check
237243
to ignore ``static`` variables declared within the scope of

clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,9 @@ Options
5252
By default the following function return types are checked:
5353
`::std::error_code`, `::std::error_condition`, `::std::errc`, `::std::expected`, `::boost::system::error_code`
5454

55+
.. option:: AllowCastToVoid
56+
57+
Controls whether casting return values to ``void`` is permitted. Default: `false`.
58+
5559
:doc:`cert-err33-c <../cert/err33-c>` is an alias of this check that checks a
5660
fixed and large set of standard library functions.

clang-tools-extra/docs/clang-tidy/checks/cert/err33-c.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ functions are checked:
189189
This check is an alias of check :doc:`bugprone-unused-return-value <../bugprone/unused-return-value>`
190190
with a fixed set of functions.
191191

192+
Suppressing issues by casting to ``void`` is enabled by default and can be
193+
disabled by setting `AllowCastToVoid` option to ``false``.
194+
192195
The check corresponds to a part of CERT C Coding Standard rule `ERR33-C.
193196
Detect and handle standard library errors
194197
<https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors>`_.

clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value-custom.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,35 @@ void fun(int);
4747

4848
void warning() {
4949
fun();
50-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used
51-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
50+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
5251

5352
(fun());
54-
// CHECK-NOTES: [[@LINE-1]]:4: warning: the value {{.*}} should be used
55-
// CHECK-NOTES: [[@LINE-2]]:4: note: cast {{.*}} this warning
53+
// CHECK-MESSAGES: [[@LINE-1]]:4: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
54+
55+
(void)fun();
56+
// CHECK-MESSAGES: [[@LINE-1]]:9: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
5657

5758
ns::Outer::Inner ObjA1;
5859
ObjA1.memFun();
59-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
60-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
60+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
6161

6262
ns::AliasName::Inner ObjA2;
6363
ObjA2.memFun();
64-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
65-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
64+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
6665

6766
ns::Derived ObjA3;
6867
ObjA3.memFun();
69-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
70-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
68+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
7169

7270
ns::Type::staticFun();
73-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
74-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
71+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
7572

7673
ns::ClassTemplate<int> ObjA4;
7774
ObjA4.memFun();
78-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
79-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
75+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
8076

8177
ns::ClassTemplate<int>::staticFun();
82-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
83-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
78+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
8479
}
8580

8681
void noWarning() {

clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %check_clang_tidy %s bugprone-unused-return-value %t -- -- -fexceptions
1+
// RUN: %check_clang_tidy %s bugprone-unused-return-value %t -- \
2+
// RUN: --config="{CheckOptions: {bugprone-unused-return-value.AllowCastToVoid: true}}" -- -fexceptions
23

34
namespace std {
45

@@ -81,121 +82,125 @@ std::error_code errorFunc() {
8182

8283
void warning() {
8384
std::async(increment, 42);
84-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used
85-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
85+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
86+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
8687

8788
std::async(std::launch::async, increment, 42);
88-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
89-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
89+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
90+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
9091

9192
Foo F;
9293
std::launder(&F);
93-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
94-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
94+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
95+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
9596

9697
std::remove(nullptr, nullptr, 1);
97-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
98-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
98+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
99+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
99100

100101
std::remove_if(nullptr, nullptr, nullptr);
101-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
102-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
102+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
103+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
103104

104105
std::unique(nullptr, nullptr);
105-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
106-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
106+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
107+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
107108

108109
std::unique_ptr<Foo> UPtr;
109110
UPtr.release();
110-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
111-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
111+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
112+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
112113

113114
std::string Str;
114115
Str.empty();
115-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
116-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
116+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
117+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
118+
119+
(int)Str.empty();
120+
// CHECK-MESSAGES: [[@LINE-1]]:8: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
121+
// CHECK-MESSAGES: [[@LINE-2]]:8: note: cast the expression to void to silence this warning
117122

118123
std::vector<Foo> Vec;
119124
Vec.empty();
120-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
121-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
125+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
126+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
122127

123128
// test discarding return values inside different kinds of statements
124129

125130
auto Lambda = [] { std::remove(nullptr, nullptr, 1); };
126-
// CHECK-NOTES: [[@LINE-1]]:22: warning: the value {{.*}} should be used
127-
// CHECK-NOTES: [[@LINE-2]]:22: note: cast {{.*}} this warning
131+
// CHECK-MESSAGES: [[@LINE-1]]:22: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
132+
// CHECK-MESSAGES: [[@LINE-2]]:22: note: cast the expression to void to silence this warning
128133

129134
if (true)
130135
std::remove(nullptr, nullptr, 1);
131-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
132-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
136+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
137+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
133138
else if (true)
134139
std::remove(nullptr, nullptr, 1);
135-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
136-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
140+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
141+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
137142
else
138143
std::remove(nullptr, nullptr, 1);
139-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
140-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
144+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
145+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
141146

142147
while (true)
143148
std::remove(nullptr, nullptr, 1);
144-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
145-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
149+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
150+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
146151

147152
do
148153
std::remove(nullptr, nullptr, 1);
149-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
150-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
154+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
155+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
151156
while (true);
152157

153158
for (;;)
154159
std::remove(nullptr, nullptr, 1);
155-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
156-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
160+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
161+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
157162

158163
for (std::remove(nullptr, nullptr, 1);;)
159-
// CHECK-NOTES: [[@LINE-1]]:8: warning: the value {{.*}} should be used
160-
// CHECK-NOTES: [[@LINE-2]]:8: note: cast {{.*}} this warning
164+
// CHECK-MESSAGES: [[@LINE-1]]:8: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
165+
// CHECK-MESSAGES: [[@LINE-2]]:8: note: cast the expression to void to silence this warning
161166
;
162167

163168
for (;; std::remove(nullptr, nullptr, 1))
164-
// CHECK-NOTES: [[@LINE-1]]:11: warning: the value {{.*}} should be used
165-
// CHECK-NOTES: [[@LINE-2]]:11: note: cast {{.*}} this warning
169+
// CHECK-MESSAGES: [[@LINE-1]]:11: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
170+
// CHECK-MESSAGES: [[@LINE-2]]:11: note: cast the expression to void to silence this warning
166171
;
167172

168173
for (auto C : "foo")
169174
std::remove(nullptr, nullptr, 1);
170-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
171-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
175+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
176+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
172177

173178
switch (1) {
174179
case 1:
175180
std::remove(nullptr, nullptr, 1);
176-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
177-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
181+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
182+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
178183
break;
179184
default:
180185
std::remove(nullptr, nullptr, 1);
181-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
182-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
186+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
187+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
183188
break;
184189
}
185190

186191
try {
187192
std::remove(nullptr, nullptr, 1);
188-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
189-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
193+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
194+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
190195
} catch (...) {
191196
std::remove(nullptr, nullptr, 1);
192-
// CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
193-
// CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
197+
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
198+
// CHECK-MESSAGES: [[@LINE-2]]:5: note: cast the expression to void to silence this warning
194199
}
195200

196201
errorFunc();
197-
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
198-
// CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
202+
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
203+
// CHECK-MESSAGES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
199204
}
200205

201206
void noWarning() {

0 commit comments

Comments
 (0)