Reviewed handling of >> in return statements in C files in UninitVar checking
This commit is contained in:
parent
f0f69ed818
commit
7f5950967e
|
@ -430,7 +430,7 @@ private:
|
|||
// is there assignment or ternary operator in the return statement?
|
||||
bool assignment = false;
|
||||
for (const Token *tok2 = tok.next(); tok2 && tok2->str() != ";"; tok2 = tok2->next()) {
|
||||
if (tok2->str() == "=" || tok2->str() == ">>" || tok2->str() == "?" || Token::Match(tok2, "(|, &")) {
|
||||
if (tok2->str() == "=" || (!isC && tok2->str() == ">>") || tok2->str() == "?" || Token::Match(tok2, "(|, &")) {
|
||||
assignment = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -222,11 +222,19 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("static int foo() {\n"
|
||||
" int ret;\n"
|
||||
" return cin >> ret;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
{
|
||||
checkUninitVar("static int foo() {\n"
|
||||
" int ret;\n"
|
||||
" return cin >> ret;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("static int foo() {\n"
|
||||
" int ret;\n"
|
||||
" return cin >> ret;\n"
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("[test.c:3]: (error) Uninitialized variable: ret\n", errout.str());
|
||||
}
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue