File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ struct ReverseTraversal {
173173 if (!continueB)
174174 break ;
175175 valueFlowGenericForward (assignTop->astOperand2 (), analyzer, settings);
176- tok = previousBeforeAstLeftmostLeaf (assignTop);
176+ tok = previousBeforeAstLeftmostLeaf (assignTop)-> next () ;
177177 continue ;
178178 }
179179 if (tok->str () == " }" ) {
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ class TestNullPointer : public TestFixture {
105105 TEST_CASE (nullpointer62);
106106 TEST_CASE (nullpointer63);
107107 TEST_CASE (nullpointer64);
108+ TEST_CASE (nullpointer65); // #9980
108109 TEST_CASE (nullpointer_addressOf); // address of
109110 TEST_CASE (nullpointerSwitch); // #2626
110111 TEST_CASE (nullpointer_cast); // #4692
@@ -2011,6 +2012,26 @@ class TestNullPointer : public TestFixture {
20112012 ASSERT_EQUALS (" " , errout.str ());
20122013 }
20132014
2015+ void nullpointer65 () {
2016+ check (" struct A {\n "
2017+ " double get();\n "
2018+ " };\n "
2019+ " double x;\n "
2020+ " double run(A** begin, A** end) {\n "
2021+ " A* a = nullptr;\n "
2022+ " while (begin != end) {\n "
2023+ " a = *begin;\n "
2024+ " x = a->get();\n "
2025+ " ++begin;\n "
2026+ " }\n "
2027+ " x = 0;\n "
2028+ " if (a)\n "
2029+ " return a->get();\n "
2030+ " return 0;\n "
2031+ " }\n " );
2032+ ASSERT_EQUALS (" " , errout.str ());
2033+ }
2034+
20142035 void nullpointer_addressOf () { // address of
20152036 check (" void f() {\n "
20162037 " struct X *x = 0;\n "
You can’t perform that action at this time.
0 commit comments