Fix issue 9855: false positive: uninitvar (#2754)
This commit is contained in:
parent
7cf3909275
commit
9ec27c112f
|
@ -209,6 +209,7 @@ struct ForwardTraversal {
|
|||
}
|
||||
|
||||
Progress updateLoop(Token* endBlock, Token* condTok, Token* initTok = nullptr, Token* stepTok = nullptr) {
|
||||
const bool isDoWhile = precedes(endBlock, condTok);
|
||||
ForwardAnalyzer::Action bodyAnalysis = analyzeScope(endBlock);
|
||||
ForwardAnalyzer::Action allAnalysis = bodyAnalysis;
|
||||
if (condTok)
|
||||
|
@ -225,7 +226,7 @@ struct ForwardTraversal {
|
|||
return Progress::Break;
|
||||
}
|
||||
// Traverse condition after lowering
|
||||
if (condTok) {
|
||||
if (condTok && (!isDoWhile || !bodyAnalysis.isModified())) {
|
||||
if (updateRecursive(condTok) == Progress::Break)
|
||||
return Progress::Break;
|
||||
|
||||
|
|
|
@ -4430,6 +4430,16 @@ private:
|
|||
" f += 1;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
valueFlowUninit("unsigned char get();\n"
|
||||
"char f() {\n"
|
||||
" unsigned char c;\n"
|
||||
" do {\n"
|
||||
" c = get();\n"
|
||||
" } while (isalpha(c) == 0);\n"
|
||||
" return static_cast<char>(c);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar_ipa() {
|
||||
|
|
Loading…
Reference in New Issue