You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/testnullpointer.cpp
+40Lines changed: 40 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,7 @@ class TestNullPointer : public TestFixture {
114
114
TEST_CASE(nullpointer71); // #10178
115
115
TEST_CASE(nullpointer72); // #10215
116
116
TEST_CASE(nullpointer73); // #10321
117
+
TEST_CASE(nullpointer74);
117
118
TEST_CASE(nullpointer_addressOf); // address of
118
119
TEST_CASE(nullpointerSwitch); // #2626
119
120
TEST_CASE(nullpointer_cast); // #4692
@@ -2289,6 +2290,45 @@ class TestNullPointer : public TestFixture {
2289
2290
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:10]: (warning) Either the condition 'ptr!=nullptr' is redundant or there is possible null pointer dereference: ptr.\n", errout.str());
2290
2291
}
2291
2292
2293
+
voidnullpointer74() {
2294
+
check("struct d {\n"
2295
+
" d* e();\n"
2296
+
"};\n"
2297
+
"void g(d* f) {\n"
2298
+
" do {\n"
2299
+
" f = f->e();\n"
2300
+
" if (f) {}\n"
2301
+
" } while (0);\n"
2302
+
"}\n");
2303
+
ASSERT_EQUALS("", errout.str());
2304
+
2305
+
check("struct d {\n"
2306
+
" d* e();\n"
2307
+
"};\n"
2308
+
"void g(d* f, int i) {\n"
2309
+
" do {\n"
2310
+
" i--;\n"
2311
+
" f = f->e();\n"
2312
+
" if (f) {}\n"
2313
+
" } while (i > 0);\n"
2314
+
"}\n");
2315
+
ASSERT_EQUALS(
2316
+
"[test.cpp:8] -> [test.cpp:7]: (warning) Either the condition 'f' is redundant or there is possible null pointer dereference: f.\n",
0 commit comments