Skip to content

Commit ae15987

Browse files
Update testnullpointer.cpp
1 parent 3a9750e commit ae15987

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/testnullpointer.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3611,6 +3611,27 @@ class TestNullPointer : public TestFixture {
36113611
"}\n");
36123612
ASSERT_EQUALS("[test.cpp:8:21] -> [test.cpp:10:18]: (warning) Either the condition 'tok=tok->next' is redundant or there is possible null pointer dereference: tok. [nullPointerRedundantCheck]\n",
36133613
errout_str());
3614+
3615+
check("void f(const A* a, const B* b) {\n" // #6282
3616+
" if (b && a) {}\n"
3617+
" if (a != b && b->value) {}\n"
3618+
"}\n");
3619+
ASSERT_EQUALS("[test.cpp:2:9] -> [test.cpp:3:19]: (warning) Either the condition 'b' is redundant or there is possible null pointer dereference: b. [nullPointerRedundantCheck]\n",
3620+
errout_str());
3621+
3622+
check("void f(int* a) {\n" // #12859
3623+
" if (!a)\n"
3624+
" x;\n"
3625+
" *a = 0;\n"
3626+
"}\n"
3627+
"void g(int* a) {\n"
3628+
" if (!a)\n"
3629+
" x();\n"
3630+
" *a = 0;\n"
3631+
"}\n", dinit(CheckOptions, $.inconclusive = true));
3632+
ASSERT_EQUALS("[test.cpp:2:9] -> [test.cpp:4:6]: (warning, inconclusive) Either the condition '!a' is redundant or there is possible null pointer dereference: a. [nullPointerRedundantCheck]\n"
3633+
"[test.cpp:7:9] -> [test.cpp:9:6]: (warning, inconclusive) Either the condition '!a' is redundant or there is possible null pointer dereference: a. [nullPointerRedundantCheck]\n",
3634+
errout_str());
36143635
}
36153636

36163637
// Test CheckNullPointer::nullConstantDereference

0 commit comments

Comments
 (0)