Fix issue 9980: FP nullPointerRedundantCheck - condition after while loop (#2912)
This commit is contained in:
parent
317a2d039f
commit
f6399c4cba
|
@ -173,7 +173,7 @@ struct ReverseTraversal {
|
|||
if (!continueB)
|
||||
break;
|
||||
valueFlowGenericForward(assignTop->astOperand2(), analyzer, settings);
|
||||
tok = previousBeforeAstLeftmostLeaf(assignTop);
|
||||
tok = previousBeforeAstLeftmostLeaf(assignTop)->next();
|
||||
continue;
|
||||
}
|
||||
if (tok->str() == "}") {
|
||||
|
|
|
@ -105,6 +105,7 @@ private:
|
|||
TEST_CASE(nullpointer62);
|
||||
TEST_CASE(nullpointer63);
|
||||
TEST_CASE(nullpointer64);
|
||||
TEST_CASE(nullpointer65); // #9980
|
||||
TEST_CASE(nullpointer_addressOf); // address of
|
||||
TEST_CASE(nullpointerSwitch); // #2626
|
||||
TEST_CASE(nullpointer_cast); // #4692
|
||||
|
@ -2011,6 +2012,26 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer65() {
|
||||
check("struct A {\n"
|
||||
" double get();\n"
|
||||
"};\n"
|
||||
"double x;\n"
|
||||
"double run(A** begin, A** end) {\n"
|
||||
" A* a = nullptr;\n"
|
||||
" while (begin != end) {\n"
|
||||
" a = *begin;\n"
|
||||
" x = a->get();\n"
|
||||
" ++begin;\n"
|
||||
" }\n"
|
||||
" x = 0;\n"
|
||||
" if (a)\n"
|
||||
" return a->get();\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer_addressOf() { // address of
|
||||
check("void f() {\n"
|
||||
" struct X *x = 0;\n"
|
||||
|
|
Loading…
Reference in New Issue