Skip to content

Commit 2129a66

Browse files
Update testnullpointer.cpp
1 parent 12726ff commit 2129a66

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/testnullpointer.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,6 +3020,21 @@ class TestNullPointer : public TestFixture {
30203020
" f(nullptr, nullptr);\n"
30213021
"}\n", dinit(CheckOptions, $.inconclusive = true));
30223022
ASSERT_EQUALS("", errout_str());
3023+
3024+
check("struct T {\n" // #14308
3025+
" bool b{};\n"
3026+
" T* next{};\n"
3027+
"};\n"
3028+
"bool g(const T*& r) {\n"
3029+
" const T* t = r;\n"
3030+
" r = t->next;\n"
3031+
" return t->b;\n"
3032+
"}\n"
3033+
"void f(const T* tok) {\n"
3034+
" if (g(tok)) {}\n"
3035+
" if (tok) {}\n"
3036+
"}\n", dinit(CheckOptions, $.inconclusive = true));
3037+
ASSERT_EQUALS("", errout_str());
30233038
}
30243039

30253040
// Check if pointer is null and the dereference it

0 commit comments

Comments
 (0)