Fix FP with std::array (#4497)
* Fix #1655 wrong usage of std::string in memcpy * Fix memsetClass FP * Fix #8619 FN memset on container containing structs with containers * Token::Match * Use AST * simpleMatch * Fix FP with std::array * simpleMatch
This commit is contained in:
parent
0bb82b70d9
commit
d608bec414
|
@ -1361,7 +1361,8 @@ void CheckClass::checkMemset()
|
|||
if (numIndirToVariableType == 1)
|
||||
type = var->typeScope();
|
||||
|
||||
if (!type && !var->isPointer() && mSettings->library.detectContainerOrIterator(var->typeStartToken())) {
|
||||
if (!type && !var->isPointer() && !Token::simpleMatch(var->typeStartToken(), "std :: array") &&
|
||||
mSettings->library.detectContainerOrIterator(var->typeStartToken())) {
|
||||
memsetError(tok, tok->str(), var->getTypeName(), {}, /*isContainer*/ true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3146,6 +3146,12 @@ private:
|
|||
" f<P>(Dst, Src, 2);\n"
|
||||
"}\n", s);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkNoMemset("void f() {\n"
|
||||
" std::array<char, 4> a;\n"
|
||||
" std::memset(&a, 0, 4);\n"
|
||||
"}\n", s);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void memsetOnInvalid() { // Ticket #5425
|
||||
|
|
Loading…
Reference in New Issue