Uninitialized variables; Fixed FP in inner for loop
This commit is contained in:
parent
fa72ec20b2
commit
4ad90bf6f1
|
@ -902,8 +902,8 @@ const Token* CheckUninitVar::checkLoopBodyRecursive(const Token *start, const Va
|
|||
continue;
|
||||
const Token *bodyStart = top->link()->next();
|
||||
const Token *errorToken1 = checkLoopBodyRecursive(bodyStart, var, alloc, membervar, bailout);
|
||||
if (errorToken1)
|
||||
return errorToken1;
|
||||
if (!errorToken)
|
||||
errorToken = errorToken1;
|
||||
if (bailout)
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -1259,6 +1259,16 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: x\n", errout.str());
|
||||
|
||||
checkUninitVar("void foo(int n) {\n"
|
||||
" int one[10];\n"
|
||||
" for (int rank = 0; rank < n; ++rank) {\n"
|
||||
" for (int i=0;i<rank;i++)\n"
|
||||
" f = one[i];\n"
|
||||
" one[rank] = -1;\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Ticket #2226: C++0x loop
|
||||
checkUninitVar("void f() {\n"
|
||||
" container c;\n"
|
||||
|
|
Loading…
Reference in New Issue