Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .selfcheck_suppressions
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/reverseanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions test/testnullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading