unused struct member: Added checks

This commit is contained in:
Daniel Marjamäki 2008-11-10 20:59:18 +00:00
parent 607a4337ec
commit f752b0e375
1 changed files with 42 additions and 0 deletions

View File

@ -56,6 +56,8 @@ private:
void run() void run()
{ {
TEST_CASE( structmember1 ); TEST_CASE( structmember1 );
TEST_CASE( structmember2 );
TEST_CASE( structmember3 );
} }
void structmember1() void structmember1()
@ -71,6 +73,46 @@ private:
"[test.cpp:4]: struct member 'abc::c' is never read\n"), errout.str() ); "[test.cpp:4]: struct member 'abc::c' is never read\n"), errout.str() );
} }
void structmember2()
{
check( "struct ABC\n"
"{\n"
" int a;\n"
" int b;\n"
" int c;\n"
"};\n"
"\n"
"void foo()\n"
"{\n"
" struct ABC abc;\n"
" int a = abc.a;\n"
" int b = abc.b;\n"
" int c = abc.c;\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
void structmember3()
{
check( "struct ABC\n"
"{\n"
" int a;\n"
" int b;\n"
" int c;\n"
"};\n"
"\n"
"static struct ABC abc[] = { {1, 2, 3} };\n"
"\n"
"void foo()\n"
"{\n"
" int a = abc[0].a;\n"
" int b = abc[0].b;\n"
" int c = abc[0].c;\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
}; };
REGISTER_TEST( TestUnusedVar ) REGISTER_TEST( TestUnusedVar )