From 2c697c6252818e1d3013cc885e281f1f8da3a733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 9 May 2007 18:10:10 +0000 Subject: [PATCH] Check 'operator=()' --- main.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 3a256e733..ff76362c4 100644 --- a/main.cpp +++ b/main.cpp @@ -29,6 +29,7 @@ void Tokenize(const char FileName[]); void CheckConstructors(); void CheckUnusedPrivateFunctions(); void CheckMemset(); +void CheckOperatorEq1(); // Warning upon "void operator=(.." // Function void CheckMovableVariableDeclaration(); @@ -86,7 +87,11 @@ static void CppCheck(const char FileName[]) // This function can do dangerous things if used wrong. CheckMemset(); - WarningHeaderWithImplementation(); + CheckOperatorEq1(); + + // Found implementation in header + // Since this is not a bug I am not enabling it right now + //WarningHeaderWithImplementation(); // Warning upon c-style pointer casts WarningOldStylePointerCast(); @@ -868,6 +873,23 @@ void CheckMemset() +//--------------------------------------------------------------------------- +// Class: "void operator=(" +//--------------------------------------------------------------------------- + +void CheckOperatorEq1() +{ + const char *pattern[] = {"void", "operator", "=", "(", NULL}; + if (TOKEN *tok = findtoken(tokens,pattern)) + { + std::ostringstream ostr; + ostr << FileLine(tok) << ": 'operator=' should return something"; + ReportErr(ostr.str()); + } +} + + + //--------------------------------------------------------------------------- // HEADERS - No implementation in a header