From 132aa8d0c439e8e3762e2a73a7bb45d03e2db4fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 25 Oct 2010 20:56:15 +0200 Subject: [PATCH] uninitialized variables: fixed fp when analysing loops --- lib/checkother.cpp | 2 +- test/testother.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index fd13ec343..1a93c1e79 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3778,7 +3778,7 @@ private: { while (tok) { - if (tok->str() == "{" || tok->str() == "}") + if (tok->str() == "{" || tok->str() == "}" || tok->str() == "for") return; const Token *next = parse(*tok, checks); if (next) diff --git a/test/testother.cpp b/test/testother.cpp index 99deaa633..eb6848d3e 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1801,6 +1801,16 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("void x() {\n" + " do {\n" + " Token * tok;\n" + " for (tok = a; tok; tok = tok->next())\n" + " {\n" + " }\n" + " } while (tok2);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // while.. checkUninitVar("int f()\n" "{\n"