unused struct member: bail out when casting

This commit is contained in:
Daniel Marjamäki 2009-10-17 19:31:14 +02:00
parent 2ec1b676ea
commit cb76061118
2 changed files with 13 additions and 1 deletions

View File

@ -621,7 +621,7 @@ void CheckOther::checkStructMemberUsage()
}
// Bail out if some data is casted to struct..
const std::string s("( struct " + tok->next()->str() + " * ) & %var% [");
const std::string s("( struct| " + tok->next()->str() + " * ) & %var% [");
if (Token::findmatch(tok, s.c_str()))
structname = 0;
}

View File

@ -164,6 +164,18 @@ private:
" struct AB *ab = (struct AB *)&buf[10];\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("struct AB\n"
"{\n"
" int a;\n"
" int b;\n"
"};\n"
"\n"
"void foo(char *buf)\n"
"{\n"
" struct AB *ab = (AB *)&buf[10];\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
};