Fix regression in CheckCondition (#2854)

Introduced by e2a81a382f.
This commit is contained in:
Ken-Patrick Lehrmann 2020-10-20 07:56:41 +02:00 committed by GitHub
parent 0a50d8e8f4
commit e4a54a24db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -469,7 +469,7 @@ void CheckCondition::duplicateCondition()
}
}
if (tok3->varId() > 0 &&
isVariableChanged(scope.classDef->next(), cond2, tok3->varId(), false, mSettings, mTokenizer->isCPP())) {
isVariableChanged(scope.classDef->next(), cond2, tok3->valueType()->pointer, tok3->varId(), false, mSettings, mTokenizer->isCPP())) {
modified = true;
return ChildrenToVisit::done;
}

View File

@ -3829,6 +3829,15 @@ private:
" if (b) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f(int *i) {\n"
" if (*i == 0) {\n"
" *i = 1;\n"
" }\n"
" if (*i == 0) {\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void checkInvalidTestForOverflow() {