From da7e75f69eebacead88c162b2428692c4c556e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 4 Feb 2010 20:53:04 +0100 Subject: [PATCH] Class checking: Minor refactoring when analysing memset on class --- lib/checkclass.cpp | 2 +- test/testclass.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 1f418d7d9..72483ad47 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -758,7 +758,7 @@ void CheckClass::noMemset() break; } - if (Token::Match(tstruct, "std :: %type% < %type% > %var% ;")) + if (Token::Match(tstruct, "std :: %type% < %type% *| > %var% ;")) { memsetStructError(tok, tok->str(), tstruct->strAt(2)); break; diff --git a/test/testclass.cpp b/test/testclass.cpp index 930deea1f..6cced2496 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -1492,6 +1492,16 @@ private: " memset(a, 0, sizeof(A));\n" "}"); ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str()); + + checkNoMemset("struct A\n" + "{ std::vector ints; }\n" + "\n" + "void f()\n" + "{\n" + " A a;\n" + " memset(a, 0, sizeof(A));\n" + "}"); + ASSERT_EQUALS("[test.cpp:7]: (error) Using 'memset' on struct that contains a 'std::vector'\n", errout.str()); }