This commit is contained in:
parent
d64dadcd31
commit
158f3d494e
|
@ -479,16 +479,21 @@ void CheckOther::checkRedundantAssignment()
|
||||||
// todo: check static variables
|
// todo: check static variables
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If there is a custom assignment operator => this is inconclusive
|
|
||||||
bool inconclusive = false;
|
bool inconclusive = false;
|
||||||
if (mTokenizer->isCPP() && tok->astOperand1()->valueType() && tok->astOperand1()->valueType()->typeScope) {
|
if (mTokenizer->isCPP() && tok->astOperand1()->valueType()) {
|
||||||
const std::string op = "operator" + tok->str();
|
// If there is a custom assignment operator => this is inconclusive
|
||||||
for (const Function &f : tok->astOperand1()->valueType()->typeScope->functionList) {
|
if (tok->astOperand1()->valueType()->typeScope) {
|
||||||
if (f.name() == op) {
|
const std::string op = "operator" + tok->str();
|
||||||
inconclusive = true;
|
for (const Function& f : tok->astOperand1()->valueType()->typeScope->functionList) {
|
||||||
break;
|
if (f.name() == op) {
|
||||||
|
inconclusive = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// assigning a smart pointer has side effects
|
||||||
|
if (tok->astOperand1()->valueType()->type == ValueType::SMART_POINTER)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (inconclusive && !mSettings->certainty.isEnabled(Certainty::inconclusive))
|
if (inconclusive && !mSettings->certainty.isEnabled(Certainty::inconclusive))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -7875,6 +7875,13 @@ private:
|
||||||
" e = dostuff();\n"
|
" e = dostuff();\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n" // #10143
|
||||||
|
" std::shared_ptr<int> i = g();\n"
|
||||||
|
" h();\n"
|
||||||
|
" i = nullptr;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void redundantMemWrite() {
|
void redundantMemWrite() {
|
||||||
|
|
Loading…
Reference in New Issue