From 14f12e06470d34172740452d7dbd6f12a7db7356 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= <danielm77@spray.se>
Date: Sun, 10 Oct 2010 07:57:26 +0200
Subject: [PATCH] Fixed #2078 (false negative: member variable not intialized)

---
 lib/checkclass.cpp |  2 +-
 test/testclass.cpp | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp
index ec3bce8ba..64190cec8 100644
--- a/lib/checkclass.cpp
+++ b/lib/checkclass.cpp
@@ -964,7 +964,7 @@ void CheckClass::SpaceInfo::initializeVarList(const Func &func, std::list<std::s
             std::list<Func>::const_iterator it;
             for (it = functionList.begin(); it != functionList.end(); ++it)
             {
-                if (ftok->str() == it->tokenDef->str())
+                if (ftok->str() == it->tokenDef->str() && it->type != Func::Constructor)
                     break;
             }
 
diff --git a/test/testclass.cpp b/test/testclass.cpp
index 0e6c06e88..a5678866a 100644
--- a/test/testclass.cpp
+++ b/test/testclass.cpp
@@ -55,6 +55,7 @@ private:
         TEST_CASE(uninitVar9); // ticket #1730
         TEST_CASE(uninitVar10); // ticket #1993
         TEST_CASE(uninitVar11);
+        TEST_CASE(uninitVar12); // ticket #2078
         TEST_CASE(uninitVarEnum);
         TEST_CASE(uninitVarStream);
         TEST_CASE(uninitVarTypedef);
@@ -1677,6 +1678,24 @@ private:
         ASSERT_EQUALS("[test.cpp:7]: (style) Member variable not initialized in the constructor 'A::var'\n", errout.str());
     }
 
+    void uninitVar12() // ticket #2078
+    {
+        checkUninitVar("class Point\n"
+                       "{\n"
+                       "public:\n"
+                       "    Point()\n"
+                       "    {\n"
+                       "        Point(0, 0);\n"
+                       "    }\n"
+                       "    Point(int x, int y)\n"
+                       "        : x(x), y(y)\n"
+                       "    {}\n"
+                       "    int x, y;\n"
+                       "};\n");
+        ASSERT_EQUALS("[test.cpp:4]: (style) Member variable not initialized in the constructor 'Point::x'\n"
+                      "[test.cpp:4]: (style) Member variable not initialized in the constructor 'Point::y'\n", errout.str());
+    }
+
     void uninitVarArray1()
     {
         checkUninitVar("class John\n"