Reviewed handling of << and >> in C files in CheckUninitVar
This commit is contained in:
parent
e2964c0c9e
commit
f0f69ed818
|
@ -558,7 +558,7 @@ private:
|
|||
return tok.tokAt(3);
|
||||
}
|
||||
|
||||
else if (Token::Match(tok.previous(), "<<|>>") || Token::simpleMatch(tok.next(), "=")) {
|
||||
else if ((!isC && Token::Match(tok.previous(), "<<|>>")) || Token::simpleMatch(tok.next(), "=")) {
|
||||
// TODO: Don't bail out for "<<" and ">>" if these are
|
||||
// just computations
|
||||
ExecutionPath::bailOutVar(checks, tok.varId());
|
||||
|
|
|
@ -348,14 +348,21 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("int a()\n"
|
||||
"{\n"
|
||||
checkUninitVar("int a() {\n"
|
||||
" int ret;\n"
|
||||
" std::cin >> ret;\n"
|
||||
" return ret;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("int a() {\n"
|
||||
" int ret;\n"
|
||||
" int a = value >> ret;\n"
|
||||
" return ret;\n"
|
||||
"}\n",
|
||||
"test.c");
|
||||
ASSERT_EQUALS("[test.c:3]: (error) Uninitialized variable: ret\n", errout.str());
|
||||
|
||||
checkUninitVar("void foo() {\n" // #3707
|
||||
" Node node;\n"
|
||||
" int x;\n"
|
||||
|
@ -370,6 +377,14 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("int a() {\n"
|
||||
" int ret;\n"
|
||||
" int a = value << ret;\n"
|
||||
" return ret;\n"
|
||||
"}\n",
|
||||
"test.c");
|
||||
ASSERT_EQUALS("[test.c:3]: (error) Uninitialized variable: ret\n", errout.str());
|
||||
|
||||
checkUninitVar("int a()\n"
|
||||
"{\n"
|
||||
" int ret;\n"
|
||||
|
|
Loading…
Reference in New Issue