diff --git a/.selfcheck_suppressions b/.selfcheck_suppressions index 764b8818308..69885eb2263 100644 --- a/.selfcheck_suppressions +++ b/.selfcheck_suppressions @@ -1,8 +1,6 @@ missingIncludeSystem # should not be reported - see #13387 checkersReport -# false positive - see #14308 -nullPointerRedundantCheck:externals/simplecpp/simplecpp.cpp:3246 # warnings in Qt generated code we cannot fix funcArgNamesDifferent:*/moc_checkthread.cpp diff --git a/lib/reverseanalyzer.cpp b/lib/reverseanalyzer.cpp index 671426f5d2d..6ebceb41b8f 100644 --- a/lib/reverseanalyzer.cpp +++ b/lib/reverseanalyzer.cpp @@ -298,13 +298,13 @@ namespace { if (!condTok) break; Analyzer::Action condAction = analyzeRecursive(condTok); + if (condAction.isModified()) + break; const bool inLoop = Token::Match(condTok->astTop()->previous(), "for|while ("); // Evaluate condition of for and while loops first if (inLoop) { if (Token::findmatch(tok->link(), "goto|break", tok)) break; - if (condAction.isModified()) - break; valueFlowGenericForward(condTok, analyzer, tokenlist, errorLogger, settings); } Token* thenEnd; diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 96e188075e4..f2664b05285 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -3787,6 +3787,21 @@ class TestNullPointer : public TestFixture { " g(x);\n" "}"); ASSERT_EQUALS("", errout_str()); + + check("struct T {\n" // #14308 + " bool b{};\n" + " T* next{};\n" + "};\n" + "bool g(const T*& r) {\n" + " const T* t = r;\n" + " r = t->next;\n" + " return t->b;\n" + "}\n" + "void f(const T* tok) {\n" + " if (g(tok)) {}\n" + " if (tok) {}\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void nullpointerExit() {