* Fix #11108 FP unreadVariable with unique_ptr and unknown c'tor * Fix test
This commit is contained in:
parent
b16d12b5fb
commit
4894cdab8f
|
@ -1199,7 +1199,7 @@ void CheckUnusedVar::checkFunctionVariableUsage()
|
||||||
if (tok->str() == "=" && !(tok->valueType() && tok->valueType()->pointer) && isRaiiClass(tok->valueType(), mTokenizer->isCPP(), false))
|
if (tok->str() == "=" && !(tok->valueType() && tok->valueType()->pointer) && isRaiiClass(tok->valueType(), mTokenizer->isCPP(), false))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const bool isPointer = tok->valueType() && tok->valueType()->pointer;
|
const bool isPointer = tok->valueType() && (tok->valueType()->pointer || tok->valueType()->type == ValueType::SMART_POINTER);
|
||||||
|
|
||||||
if (tok->isName()) {
|
if (tok->isName()) {
|
||||||
if (isRaiiClass(tok->valueType(), mTokenizer->isCPP(), false))
|
if (isRaiiClass(tok->valueType(), mTokenizer->isCPP(), false))
|
||||||
|
|
|
@ -6012,6 +6012,12 @@ private:
|
||||||
" return *p;\n"
|
" return *p;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
functionVariableUsage("struct S { S(); };\n" // #11108
|
||||||
|
"void f(std::unique_ptr<S> p) {\n"
|
||||||
|
" p = nullptr;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ticket #3104 - false positive when variable is read with "if (NOT var)"
|
// ticket #3104 - false positive when variable is read with "if (NOT var)"
|
||||||
|
|
Loading…
Reference in New Issue