Fixed #4165 (False positive:(error) Uninitialized variable: here)
This commit is contained in:
parent
95b6288d25
commit
96b1890797
|
@ -1325,7 +1325,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer) const
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Token::Match(vartok->next(), "++|--|%op%"))
|
||||
if (Token::Match(vartok->next(), "++|--|%op%") && !Token::simpleMatch(vartok->tokAt(-2), "( &"))
|
||||
return true;
|
||||
|
||||
if (vartok->strAt(1) == "]")
|
||||
|
|
|
@ -2002,6 +2002,12 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: x\n", errout.str());
|
||||
|
||||
checkUninitVar2("void f() {\n" // #4165 - fp when & is used as address-of in condition
|
||||
" int x;\n"
|
||||
" if (&x < p) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ?:
|
||||
checkUninitVar2("int f(int *ptr) {\n"
|
||||
" int a;\n"
|
||||
|
|
Loading…
Reference in New Issue