parent
dd869cf808
commit
5e59652fd3
|
@ -166,6 +166,7 @@ private:
|
|||
TEST_CASE(array_index_72); // #11784
|
||||
TEST_CASE(array_index_73); // #11530
|
||||
TEST_CASE(array_index_74); // #11088
|
||||
TEST_CASE(array_index_75);
|
||||
TEST_CASE(array_index_multidim);
|
||||
TEST_CASE(array_index_switch_in_for);
|
||||
TEST_CASE(array_index_for_in_for); // FP: #2634
|
||||
|
@ -1976,6 +1977,18 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// #1644
|
||||
void array_index_75()
|
||||
{
|
||||
check("void f() {\n"
|
||||
" char buf[10];\n"
|
||||
" int i = 10;\n"
|
||||
" while (i >= 3)\n"
|
||||
" buf[i--] = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Array 'buf[10]' accessed at index 10, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
void array_index_multidim() {
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
|
|
|
@ -2752,6 +2752,15 @@ private:
|
|||
" return 0;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:7]: (error) Null pointer dereference: myNull\n", errout.str());
|
||||
|
||||
check("struct T { bool g() const; };\n"
|
||||
"void f(T* p) {\n"
|
||||
" if (!p)\n"
|
||||
" return;\n"
|
||||
" while (p->g())\n"
|
||||
" p = nullptr;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (warning) Possible null pointer dereference: p\n", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer94() // #11040
|
||||
|
|
|
@ -798,6 +798,14 @@ private:
|
|||
" ASSERT((void*)(\"def\") == 0);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class C {\n" // #6109
|
||||
" void check(const char code[], bool validate = true, const char* filename = \"test.cpp\");\n"
|
||||
" void f() {\n"
|
||||
" check(\"class A<B&, C>;\", \"test.C\");\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (warning) Conversion of string literal \"test.C\" to bool always evaluates to true.\n", errout.str());
|
||||
}
|
||||
|
||||
void deadStrcmp() {
|
||||
|
|
Loading…
Reference in New Issue