Added test case for #6341.

This commit is contained in:
orbitcowboy 2015-01-22 06:37:09 +01:00
parent 57404ae80a
commit dd241501f3
1 changed files with 22 additions and 0 deletions

View File

@ -1671,6 +1671,28 @@ private:
ASSERT_EQUALS("[test.c:3]: (error) Uninitialized variable: ret\n", errout.str()); ASSERT_EQUALS("[test.c:3]: (error) Uninitialized variable: ret\n", errout.str());
} }
// Ticket #6341- False negative
{
checkUninitVarB("wchar_t f() { int i; return btowc(i); }");
ASSERT_EQUALS("[test.cpp:1]: (error) Uninitialized variable: i\n", errout.str());
checkUninitVarB("wchar_t f(int i) { return btowc(i); }");
ASSERT_EQUALS("", errout.str());
// Avoid a potential false positive (#6341)
checkUninitVarB(
"void setvalue(int &x) {\n"
" x = 0;\n"
" return 123;\n"
"}\n"
"int f() {\n"
" int x;\n"
" return setvalue(x);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
// Ticket #2146 - False negative // Ticket #2146 - False negative
checkUninitVar("int f(int x) {\n" checkUninitVar("int f(int x) {\n"
" int y;\n" " int y;\n"