#3838 added more testcases.

This commit is contained in:
Ettl Martin 2013-03-14 09:36:38 +01:00
parent 19c430530f
commit c8798b2207
1 changed files with 19 additions and 2 deletions

View File

@ -1489,14 +1489,31 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
// avoid FP (example taken from #3838)
// avoid FPs (modified examples taken from #3838)
check("struct AB { int a[10]; int b[10]; };\n"
"int main() {\n"
" struct AB ab;\n"
" int * p = &ab[0].a[10]; \n"
" int * p = &ab.a[10]; \n"
" return 0;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("struct AB { int a[10]; int b[10]; };\n"
"int main() {\n"
" struct AB ab[1];\n"
" int * p = &ab[0].a[10]; \n"
" return 0;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("struct AB { int a[10]; int b[10]; };\n"
"int main() {\n"
" struct AB ab[1];\n"
" int * p = &ab[10].a[0]; \n"
" return 0;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Array 'ab[1]' accessed at index 10, which is out of bounds.\n", errout.str());
}
void array_index_44() { // #3979 (false positive)