value flow: don't perform value flow analysis in sizeof/typeof expressions

This commit is contained in:
Daniel Marjamäki 2014-01-11 21:10:01 +01:00
parent 680d3f1312
commit 3625d179e5
2 changed files with 11 additions and 0 deletions

View File

@ -227,6 +227,10 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, ErrorLogger *errorLog
break;
}
// skip sizeof..
if (tok2->str() == ")" && Token::Match(tok2->link()->previous(), "typeof|sizeof ("))
tok2 = tok2->link();
if (tok2->str() == "}") {
if (Token::findmatch(tok2->link(), "%varid%", tok2, varid)) {
if (settings->debugwarnings)

View File

@ -182,6 +182,13 @@ private:
"}";
ASSERT_EQUALS(true, testValueOfX(code, 2U, 123));
// skip sizeof
code = "void f(int *x) {\n"
" sizeof(x[0]);\n"
" if (x==63){}\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 2U, 63));
// bailout: if/else/etc
bailout("void f(int x) {\n"
" if (x != 123) { b = x; }\n"