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"