value flow: don't perform value flow analysis in sizeof/typeof expressions
This commit is contained in:
parent
680d3f1312
commit
3625d179e5
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue