parent
8bf8070923
commit
7b97230dd2
|
@ -1282,8 +1282,9 @@ void CheckUnusedVar::checkFunctionVariableUsage()
|
||||||
FwdAnalysis fwdAnalysis(mTokenizer->isCPP(), mSettings->library);
|
FwdAnalysis fwdAnalysis(mTokenizer->isCPP(), mSettings->library);
|
||||||
const Token* scopeEnd = getEndOfExprScope(expr, scope, /*smallest*/ false);
|
const Token* scopeEnd = getEndOfExprScope(expr, scope, /*smallest*/ false);
|
||||||
if (fwdAnalysis.unusedValue(expr, start, scopeEnd)) {
|
if (fwdAnalysis.unusedValue(expr, start, scopeEnd)) {
|
||||||
if (!bailoutTypeName.empty() && bailoutTypeName != "auto") {
|
if (!bailoutTypeName.empty()) {
|
||||||
reportLibraryCfgError(tok, bailoutTypeName);
|
if (bailoutTypeName != "auto")
|
||||||
|
reportLibraryCfgError(tok, bailoutTypeName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3676,9 +3676,9 @@ void stdbind()
|
||||||
// TODO cppcheck-suppress ignoredReturnValue #9369
|
// TODO cppcheck-suppress ignoredReturnValue #9369
|
||||||
std::bind(stdbind_helper, 1);
|
std::bind(stdbind_helper, 1);
|
||||||
|
|
||||||
// cppcheck-suppress unreadVariable
|
// TODO cppcheck-suppress unreadVariable
|
||||||
auto f1 = std::bind(stdbind_helper, _1);
|
auto f1 = std::bind(stdbind_helper, _1);
|
||||||
// cppcheck-suppress unreadVariable
|
// TODO cppcheck-suppress unreadVariable
|
||||||
auto f2 = std::bind(stdbind_helper, 10);
|
auto f2 = std::bind(stdbind_helper, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3241,6 +3241,12 @@ private:
|
||||||
" auto&& g = std::lock_guard<std::mutex> { mutex };\n"
|
" auto&& g = std::lock_guard<std::mutex> { mutex };\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
TODO_ASSERT_EQUALS("", "[test.cpp:2]: (style) Variable 'g' is assigned a value that is never used.\n", errout.str());
|
TODO_ASSERT_EQUALS("", "[test.cpp:2]: (style) Variable 'g' is assigned a value that is never used.\n", errout.str());
|
||||||
|
|
||||||
|
functionVariableUsage("void f() {\n"
|
||||||
|
" auto a = RAII();\n"
|
||||||
|
" auto b { RAII() };\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void localvar47() { // #6603
|
void localvar47() { // #6603
|
||||||
|
@ -5808,10 +5814,13 @@ private:
|
||||||
" auto r = std::pair<std::string, std::string>(\"a\", \"b\");\n"
|
" auto r = std::pair<std::string, std::string>(\"a\", \"b\");\n"
|
||||||
" auto s = std::pair<std::string, std::string>{ \"a\", \"b\" };\n"
|
" auto s = std::pair<std::string, std::string>{ \"a\", \"b\" };\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'p' is assigned a value that is never used.\n"
|
TODO_ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'p' is assigned a value that is never used.\n"
|
||||||
"[test.cpp:3]: (style) Variable 'q' is assigned a value that is never used.\n"
|
"[test.cpp:3]: (style) Variable 'q' is assigned a value that is never used.\n"
|
||||||
"[test.cpp:4]: (style) Variable 'r' is assigned a value that is never used.\n"
|
"[test.cpp:4]: (style) Variable 'r' is assigned a value that is never used.\n"
|
||||||
"[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n", errout.str());
|
"[test.cpp:5]: (style) Variable 's' is assigned a value that is never used.\n",
|
||||||
|
"[test.cpp:2]: (style) Variable 'p' is assigned a value that is never used.\n"
|
||||||
|
"[test.cpp:3]: (style) Variable 'q' is assigned a value that is never used.\n",
|
||||||
|
errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void localVarClass() {
|
void localVarClass() {
|
||||||
|
|
Loading…
Reference in New Issue