Fixed #6730 (ValueFlow: inner scope does not return (continue,throw))

This commit is contained in:
Daniel Marjamäki 2015-08-11 11:21:03 +02:00
parent 7a0da68843
commit 2e78d21480
2 changed files with 9 additions and 1 deletions

View File

@ -262,7 +262,7 @@ static bool isReturn(const Token *tok)
return true; return true;
// return/goto statement // return/goto statement
prev = prev->previous(); prev = prev->previous();
while (prev && !Token::Match(prev, ";|{|}|return|goto|throw")) while (prev && !Token::Match(prev, ";|{|}|return|goto|throw|continue|break"))
prev = prev->previous(); prev = prev->previous();
return prev && prev->isName(); return prev && prev->isName();
} }

View File

@ -1283,6 +1283,14 @@ private:
"}"; "}";
ASSERT_EQUALS(false, testValueOfX(code, 5U, 5)); ASSERT_EQUALS(false, testValueOfX(code, 5U, 5));
code = "void f(int x) {\n" // #6730
" if (x == 5) {\n"
" if (z) continue; else throw e;\n"
" }\n"
" a = x;\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 5U, 5));
// TODO: float // TODO: float
code = "void f(float x) {\n" code = "void f(float x) {\n"
" if (x == 0.5) {}\n" " if (x == 0.5) {}\n"