diff --git a/src/checkclass.cpp b/src/checkclass.cpp index f9e31e1f0..50f775d4a 100644 --- a/src/checkclass.cpp +++ b/src/checkclass.cpp @@ -262,7 +262,7 @@ void CheckClass::ClassChecking_VarList_Initialize(const Token *tok1, const Token void CheckClass::constructors() { - const char pattern_class[] = "class %var% {"; + const char pattern_class[] = "class %var% [{:]"; // Locate class const Token *tok1 = Token::findmatch(_tokenizer->tokens(), pattern_class); diff --git a/test/testclass.cpp b/test/testclass.cpp index 8dae3e568..a6d81cf27 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -192,6 +192,18 @@ private: "};\n"); ASSERT_EQUALS("[test.cpp:10]: (style) Member variable not initialized in the constructor 'Fred::_code'\n", errout.str()); + + + checkUninitVar("class A{};\n" + "\n" + "class B : public A\n" + "{\n" + "public:\n" + " B() {}\n" + "private:\n" + " float f;\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:6]: (style) Member variable not initialized in the constructor 'B::f'\n", errout.str()); } void uninitVarEnum()