Skip to content

Commit 2edc114

Browse files
committed
Fix
1 parent f097cab commit 2edc114

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/forwardanalyzer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,9 @@ namespace {
208208
bool checkThen, checkElse;
209209
std::tie(checkThen, checkElse) = evalCond(condTok);
210210
if (!checkThen && !checkElse) {
211-
const bool oldAnalyzeOnly = analyzeOnly;
212-
if (!traverseUnknown && stopOnCondition(condTok) && stopUpdates()) {
211+
if (!traverseUnknown && stopOnCondition(condTok) && tok->str() != "?" && stopUpdates()) {
213212
return Progress::Continue;
214213
}
215-
if (tok->str() == "?")
216-
analyzeOnly = oldAnalyzeOnly;
217214
checkThen = true;
218215
checkElse = true;
219216
}

test/testnullpointer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,9 @@ class TestNullPointer : public TestFixture {
14031403
" if (x) p = q;\n"
14041404
" if (y ? p->x : p->y) { }\n"
14051405
"}");
1406-
TODO_ASSERT_EQUALS("[test.cpp:4]: (warning) Possible null pointer dereference: p\n", "", errout_str());
1406+
ASSERT_EQUALS("[test.cpp:4:13]: (warning) Possible null pointer dereference: p [nullPointer]\n"
1407+
"[test.cpp:4:20]: (warning) Possible null pointer dereference: p [nullPointer]\n",
1408+
errout_str());
14071409
}
14081410

14091411
void nullpointer21() { // #4038 - fp: if (x) p=q; else return;

0 commit comments

Comments
 (0)