This commit is contained in:
chrchr-github 2021-12-20 13:12:19 +01:00 committed by GitHub
parent 38de9214a8
commit e6091cbe54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View File

@ -3281,6 +3281,13 @@ private:
" g(u\"Hello\" + 7);\n" " 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()); 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());
} }

View File

@ -243,6 +243,8 @@ private:
TEST_CASE(garbageCode215); // daca@home script with extension .c TEST_CASE(garbageCode215); // daca@home script with extension .c
TEST_CASE(garbageCode216); // #7884 TEST_CASE(garbageCode216); // #7884
TEST_CASE(garbageCode217); // #10011 TEST_CASE(garbageCode217); // #10011
TEST_CASE(garbageCode218); // #8763
TEST_CASE(garbageCode219); // #10101
TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1 TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
@ -1684,6 +1686,17 @@ private:
"}"), InternalError); "}"), 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() { void syntaxErrorFirstToken() {
ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818 ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818
ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858 ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858

View File

@ -1204,6 +1204,12 @@ private:
"}", true); "}", true);
ASSERT_EQUALS("", errout.str()); 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 // Ticket #2350