From 77859b9a0f266be5dbec02b1522bfcebd18a03e4 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 30 Jun 2011 07:25:36 -0400 Subject: [PATCH] fix #2878 (derived global class not tokenized properly (class A : ::B { };)) --- lib/tokenize.cpp | 15 +++++++++++++++ test/testclass.cpp | 10 ++++++++++ 2 files changed, 25 insertions(+) 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()