Fixed #3463 (Uninitialized variable variable pointer)
This commit is contained in:
parent
112873e876
commit
01759b03f9
|
@ -1252,7 +1252,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer) const
|
|||
return false;
|
||||
}
|
||||
|
||||
if (vartok->previous()->str() != "&" || !Token::Match(vartok->tokAt(-2), "[(,=]")) {
|
||||
if (vartok->previous()->str() != "&" || !Token::Match(vartok->tokAt(-2), "[(,=?:]")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1752,6 +1752,13 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: x\n", errout.str());
|
||||
|
||||
// ?:
|
||||
checkUninitVar2("int f(int *ptr) {\n"
|
||||
" int a;\n"
|
||||
" int *p = ptr ? ptr : &a;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// = { .. }
|
||||
checkUninitVar2("int f() {\n"
|
||||
" int a;\n"
|
||||
|
|
Loading…
Reference in New Issue