Array index out of bounds: Added test case for #3428 (same name of structs)

This commit is contained in:
Daniel Marjamäki 2011-12-18 16:43:46 +01:00
parent 1ba1be4b8d
commit 7c95c6f680
1 changed files with 11 additions and 0 deletions

View File

@ -1331,6 +1331,17 @@ private:
" struct Fred { char data[3]; } fred;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void a() {\n"
" struct Fred { char data[6]; } fred;\n"
" fred.data[4] = 0;\n" // <- no error
"}\n"
"\n"
"void b() {\n"
" struct Fred { char data[3]; } fred;\n"
" fred.data[4] = 0;\n" // <- error
"}\n");
ASSERT_EQUALS("[test.cpp:8]: (error) Array 'fred.data[3]' index 4 out of bounds\n", errout.str());
}
void array_index_multidim() {