Report when using uninitialized function pointer
This commit is contained in:
parent
8a9eba980b
commit
7b986c831d
|
@ -1706,6 +1706,11 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Token::simpleMatch(tok.next(), "("))
|
||||||
|
{
|
||||||
|
use_pointer(foundError, checks, &tok);
|
||||||
|
}
|
||||||
|
|
||||||
if (Token::Match(tok.tokAt(-2), "[;{}] *"))
|
if (Token::Match(tok.tokAt(-2), "[;{}] *"))
|
||||||
{
|
{
|
||||||
if (Token::simpleMatch(tok.next(), "="))
|
if (Token::simpleMatch(tok.next(), "="))
|
||||||
|
|
|
@ -1716,6 +1716,14 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: x\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: x\n", errout.str());
|
||||||
|
|
||||||
|
|
||||||
|
// using uninitialized function pointer..
|
||||||
|
checkUninitVar("void foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" void (*f)();\n"
|
||||||
|
" f();\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: f\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue