diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1d3edeb18..9a8343226 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -430,6 +430,21 @@ void Tokenizer::createTokens(std::istream &code) addtoken("&&", lineno, FileIndex, true); continue; } + else if (ch==':' && CurrentToken.empty() && code.peek() == ' ') + { + // : + addtoken(":", lineno, FileIndex, true); + CurrentToken.clear(); + continue; + } + else if (ch==':' && CurrentToken.empty() && code.peek() == ':') + { + // :: + ch = (char)code.get(); + addtoken("::", lineno, FileIndex, true); + CurrentToken.clear(); + continue; + } else { if (CurrentToken == "#file") diff --git a/test/testclass.cpp b/test/testclass.cpp index 1b439ec37..5e9252eab 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -2232,6 +2232,16 @@ private: " } obj;\n" "};\n"); ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'LocalClass::bitsInData_' is not initialized in the constructor.\n", errout.str()); + + checkUninitVar("Object::MemFunc() {\n" + " class LocalClass : ::copy_protected {\n" + " public:\n" + " LocalClass() : copy_protected(1), dataLength_(0) {}\n" + " std::streamsize dataLength_;\n" + " double bitsInData_;\n" + " } obj;\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:4]: (warning) Member variable 'LocalClass::bitsInData_' is not initialized in the constructor.\n", errout.str()); } void uninitVarArray1()