Add test cases when sizeof is used on struct members

This commit is contained in:
Thomas Jarosch 2014-12-22 09:59:34 +01:00
parent dca65ce3da
commit bac1dfce86
1 changed files with 16 additions and 0 deletions

View File

@ -509,6 +509,22 @@ private:
" memset( ptr->bar, 0, sizeof ptr->bar );\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void f() {\n"
" struct foo {\n"
" char bar[10];\n"
" };\n"
" memset( ptr->bar, 0, sizeof ptr->bar );\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void f() {\n"
" struct foo {\n"
" char *bar;\n"
" };\n"
" memset( ptr->bar, 0, sizeof ptr->bar );\n"
"}");
TODO_ASSERT_EQUALS("[test.cpp:5]: (warning) Size of pointer 'bar' used instead of size of its data.\n", "", errout.str());
}
void sizeofDivisionMemset() {