Add test cases when sizeof is used on struct members
This commit is contained in:
parent
dca65ce3da
commit
bac1dfce86
|
@ -509,6 +509,22 @@ private:
|
||||||
" memset( ptr->bar, 0, sizeof ptr->bar );\n"
|
" memset( ptr->bar, 0, sizeof ptr->bar );\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void sizeofDivisionMemset() {
|
||||||
|
|
Loading…
Reference in New Issue