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;
|
continue;
|
||||||
const Token *bodyStart = top->link()->next();
|
const Token *bodyStart = top->link()->next();
|
||||||
const Token *errorToken1 = checkLoopBodyRecursive(bodyStart, var, alloc, membervar, bailout);
|
const Token *errorToken1 = checkLoopBodyRecursive(bodyStart, var, alloc, membervar, bailout);
|
||||||
if (errorToken1)
|
if (!errorToken)
|
||||||
return errorToken1;
|
errorToken = errorToken1;
|
||||||
if (bailout)
|
if (bailout)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1259,6 +1259,16 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: x\n", errout.str());
|
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
|
// Ticket #2226: C++0x loop
|
||||||
checkUninitVar("void f() {\n"
|
checkUninitVar("void f() {\n"
|
||||||
" container c;\n"
|
" container c;\n"
|
||||||
|
|
Loading…
Reference in New Issue