- Fixed false positive when using typeof/__alignof__
This commit is contained in:
parent
cd87699eb1
commit
c37ba4cbcf
|
@ -1603,6 +1603,10 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool cpp
|
||||||
if (vartok->previous()->str() == "return")
|
if (vartok->previous()->str() == "return")
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Passing variable to typeof
|
||||||
|
if (Token::Match(vartok->tokAt(-3), "typeof|__alignof__ ( * %var%"))
|
||||||
|
return false;
|
||||||
|
|
||||||
// Passing variable to function..
|
// Passing variable to function..
|
||||||
if (Token::Match(vartok->previous(), "[(,] %var% [,)]") || Token::Match(vartok->tokAt(-2), "[(,] & %var% [,)]")) {
|
if (Token::Match(vartok->previous(), "[(,] %var% [,)]") || Token::Match(vartok->tokAt(-2), "[(,] & %var% [,)]")) {
|
||||||
const bool address(vartok->previous()->str() == "&");
|
const bool address(vartok->previous()->str() == "&");
|
||||||
|
|
|
@ -1963,6 +1963,12 @@ private:
|
||||||
" TYPEOF(s->status);\n"
|
" TYPEOF(s->status);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("void f() {\n"
|
||||||
|
" #define w(x) ({ x z; (x*)z; })\n"
|
||||||
|
" int *n = w(typeof(*n));\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue