unused struct member: bail out when casting
This commit is contained in:
parent
2ec1b676ea
commit
cb76061118
|
@ -621,7 +621,7 @@ void CheckOther::checkStructMemberUsage()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bail out if some data is casted to struct..
|
// 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()))
|
if (Token::findmatch(tok, s.c_str()))
|
||||||
structname = 0;
|
structname = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,18 @@ private:
|
||||||
" struct AB *ab = (struct AB *)&buf[10];\n"
|
" struct AB *ab = (struct AB *)&buf[10];\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue