diff --git a/CheckClass.cpp b/CheckClass.cpp index 7e3dd4a73..2a9d8d2e6 100644 --- a/CheckClass.cpp +++ b/CheckClass.cpp @@ -8,6 +8,8 @@ #include //--------------------------------------------------------------------------- +extern bool CheckCodingStyle; + struct VAR { const char *name; @@ -216,10 +218,14 @@ void CheckConstructors() if ( ! constructor_token ) { // There's no class constructor - std::ostringstream ostr; - ostr << FileLine(tok1); - ostr << " The class '" << classname << "' has no constructor"; - ReportErr(ostr.str()); + if ( CheckCodingStyle ) + { + std::ostringstream ostr; + ostr << FileLine(tok1); + ostr << " The class '" << classname << "' has no constructor"; + ReportErr(ostr.str()); + } + tok1 = findtoken( tok1->next, pattern_classname ); continue; } diff --git a/tests.cpp b/tests.cpp index 65026021a..36e221487 100644 --- a/tests.cpp +++ b/tests.cpp @@ -16,6 +16,7 @@ //--------------------------------------------------------------------------- bool ShowAll = true; +bool CheckCodingStyle = true; bool Debug = false; //--------------------------------------------------------------------------- static unsigned int FailCount, SuccessCount; @@ -454,16 +455,16 @@ static void memleak_in_function() const char test3[] = "void f()\n" "{\n" - " Kalle *kalle;\n" + " Fred *fred;\n" " if (somecondition)\n" " {\n" - " kalle = new Kalle;\n" + " fred = new Fred;\n" " }\n" " else\n" " {\n" " return;\n" " }\n" - " delete kalle;\n" + " delete fred;\n" "}\n"; check( CheckMemoryLeak, __LINE__, test3, "" ); @@ -549,7 +550,6 @@ static void memleak_in_function() " free(a);\n" "}\n"; check( CheckMemoryLeak, __LINE__, test9, "[test.cpp:4]: Mismatching allocation and deallocation 'a'\n" ); - } //---------------------------------------------------------------------------