Fixed #5481: std::array is POD, so using memcpy (etc.) is allowed on it.
This commit is contained in:
parent
80b1271d01
commit
1e57f54917
|
@ -1054,7 +1054,7 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco
|
||||||
const Scope *typeScope = var->typeScope();
|
const Scope *typeScope = var->typeScope();
|
||||||
|
|
||||||
// check for std:: type
|
// check for std:: type
|
||||||
if (var->isStlType())
|
if (var->isStlType() && tok1->strAt(2) != "array")
|
||||||
if (allocation)
|
if (allocation)
|
||||||
mallocOnClassError(tok, tok->str(), type->classDef, "'std::" + tok1->strAt(2) + "'");
|
mallocOnClassError(tok, tok->str(), type->classDef, "'std::" + tok1->strAt(2) + "'");
|
||||||
else
|
else
|
||||||
|
|
|
@ -2507,6 +2507,15 @@ private:
|
||||||
"[test.cpp:11]: (error) Using 'memset' on struct that contains a 'std::string'.\n"
|
"[test.cpp:11]: (error) Using 'memset' on struct that contains a 'std::string'.\n"
|
||||||
"[test.cpp:12]: (error) Using 'memset' on struct that contains a 'std::string'.\n"
|
"[test.cpp:12]: (error) Using 'memset' on struct that contains a 'std::string'.\n"
|
||||||
"[test.cpp:13]: (error) Using 'memset' on struct that contains a 'std::string'.\n", errout.str());
|
"[test.cpp:13]: (error) Using 'memset' on struct that contains a 'std::string'.\n", errout.str());
|
||||||
|
|
||||||
|
checkNoMemset("class A {\n"
|
||||||
|
" std::array<int, 10> ints;\n"
|
||||||
|
"};\n"
|
||||||
|
"void f() {\n"
|
||||||
|
" A a;\n"
|
||||||
|
" memset(&a, 0, sizeof(A));\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str()); // std::array is POD (#5481)
|
||||||
}
|
}
|
||||||
|
|
||||||
void mallocOnClass() {
|
void mallocOnClass() {
|
||||||
|
|
Loading…
Reference in New Issue