From c2335f845e121f3a848209afce913e5f22d70ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 17 Dec 2010 21:20:04 +0100 Subject: [PATCH] Fixed #2306 (False positive: array of std::string is reported as uninitialized) --- lib/checkuninitvar.cpp | 1 + test/testuninitvar.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index e61b0075d..c439e9b4f 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -435,6 +435,7 @@ private: // Variable declaration for array.. if (Token::Match(vartok, "%type% %var% [") && + vartok->isStandardType() && Token::simpleMatch(vartok->tokAt(2)->link(), "] ;")) { vartok = vartok->next(); diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 27716cf70..5ad7b8248 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -946,6 +946,13 @@ private: " int b = a[0];\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar("void foo()\n" + "{\n" + " Fred a[2];\n" + " Fred b = a[0];\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } // alloc..