uninitialized variables: fixed problem when parsing loop bodies

This commit is contained in:
Daniel Marjamäki 2010-11-13 08:03:59 +01:00
parent 42fcebf3b9
commit 3303c40879
2 changed files with 9 additions and 2 deletions

View File

@ -912,8 +912,7 @@ private:
if (tok->str() == "{" || tok->str() == "}" || tok->str() == "for")
return;
const Token *next = parse(*tok, checks);
if (next)
tok = tok->next();
tok = next->next();
}
}

View File

@ -670,6 +670,14 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: k\n", errout.str());
checkUninitVar("void f() {\n"
" gchar sel[10];\n"
" for (int i = 0; i < 4; ++i) {\n"
" int sz = sizeof(sel);\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("enum ABCD { A, B, C, D };\n"
"\n"
"static void f(char *str ) {\n"