Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/testbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3258,6 +3258,13 @@ class TestBufferOverrun : public TestFixture {
" g(u\"Hello\" + 7);\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (portability) Undefined behaviour, pointer arithmetic 'u\"Hello\"+7' is out of bounds.\n", errout.str());

check("void f() {\n" // #4647
" int val = 5;\n"
" std::string hi = \"hi\" + val;\n"
" std::cout << hi << std::endl;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (portability) Undefined behaviour, pointer arithmetic '\"hi\"+val' is out of bounds.\n", errout.str());
}


Expand Down
13 changes: 13 additions & 0 deletions test/testgarbage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ class TestGarbage : public TestFixture {
TEST_CASE(garbageCode215); // daca@home script with extension .c
TEST_CASE(garbageCode216); // #7884
TEST_CASE(garbageCode217); // #10011
TEST_CASE(garbageCode218); // #8763
TEST_CASE(garbageCode219); // #10101

TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1

Expand Down Expand Up @@ -1684,6 +1686,17 @@ class TestGarbage : public TestFixture {
"}"), InternalError);
}

void garbageCode218() { // #8763
checkCode("d f(){t n0000 const[]n0000+0!=n0000,(0)}"); // don't crash
}
void garbageCode219() { // #10101
checkCode("typedef void (*func) (addr) ;\n"
"void bar(void) {\n"
" func f;\n"
" f & = (func)42;\n"
"}\n"); // don't crash
}

void syntaxErrorFirstToken() {
ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818
ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858
Expand Down
6 changes: 6 additions & 0 deletions test/testnullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,12 @@ class TestNullPointer : public TestFixture {
"}", true);
ASSERT_EQUALS("", errout.str());
}

check("void f() {\n" // #5979
" int* const crash = 0;\n"
" *crash = 0;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (error) Null pointer dereference: crash\n", errout.str());
}

// Ticket #2350
Expand Down