From e4a54a24db889f8cf35965a318a743502f90899e Mon Sep 17 00:00:00 2001 From: Ken-Patrick Lehrmann Date: Tue, 20 Oct 2020 07:56:41 +0200 Subject: [PATCH] Fix regression in CheckCondition (#2854) Introduced by e2a81a382f5333ba03d3d0b83be1d06728dc0f3b. --- lib/checkcondition.cpp | 2 +- test/testcondition.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 5badfec1e..9df091878 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -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; } diff --git a/test/testcondition.cpp b/test/testcondition.cpp index b9106094d..cf0e0fb88 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -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() {