From 24a2def3ad06592b0418547c39fec80cc5f4bc02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 24 Oct 2010 19:14:40 +0200 Subject: [PATCH] Execution Path: Fixed FP in improved handling of loop bodies --- lib/executionpath.cpp | 5 +++++ test/testother.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/executionpath.cpp b/lib/executionpath.cpp index 29cea75ba..ff0ee0e16 100644 --- a/lib/executionpath.cpp +++ b/lib/executionpath.cpp @@ -260,6 +260,11 @@ void ExecutionPath::checkScope(const Token *tok, std::list &che if (tok->str() != "switch") { + for (const Token *tok3 = tok; tok3 && tok3 != tok2; tok3 = tok3->next()) + { + if (tok3->varId()) + ExecutionPath::bailOutVar(checks, tok3->varId()); + } check->parseLoopBody(tok2->next(), checks); } diff --git a/test/testother.cpp b/test/testother.cpp index 2cf84ec19..5e5061e80 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1769,6 +1769,16 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: k\n", errout.str()); + checkUninitVar("enum ABCD { A, B, C, D };\n" + "\n" + "static void f(char *str ) {\n" + " enum ABCD i;\n" + " for (i = 0; i < D; i++) {\n" + " str[i] = 0;\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // while.. checkUninitVar("int f()\n" "{\n"