Skip to content

Commit bc83d1c

Browse files
Update testnullpointer.cpp
1 parent 08c34af commit bc83d1c

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/testnullpointer.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,6 +3710,19 @@ class TestNullPointer : public TestFixture {
37103710
" i++;\n"
37113711
"}\n");
37123712
ASSERT_EQUALS("", errout_str());
3713+
3714+
check("void f(const int* p) {\n" // #6710
3715+
" for (int i = *p; i < 5; ++i) {}\n"
3716+
" if (p) {}\n"
3717+
"}\n"
3718+
"struct S { int a; };\n"
3719+
"void g(const S* s) {\n"
3720+
" for (int i = s->a; i < 5; ++i) {}\n"
3721+
" if (s) {}\n"
3722+
"}\n");
3723+
ASSERT_EQUALS("[test.cpp:3:9] -> [test.cpp:2:19]: (warning) Either the condition 'p' is redundant or there is possible null pointer dereference: p. [nullPointerRedundantCheck]\n"
3724+
"[test.cpp:8:9] -> [test.cpp:7:18]: (warning) Either the condition 's' is redundant or there is possible null pointer dereference: s. [nullPointerRedundantCheck]\n",
3725+
errout_str());
37133726
}
37143727

37153728
void nullpointerDeadCode() {

0 commit comments

Comments
 (0)