Fixed #3509 (FP: Variable 'itemList' is not assigned a value, when << operator is used)

This commit is contained in:
Daniel Marjamäki 2012-01-23 08:02:59 +01:00
parent 9eb1a5864b
commit 9f139cf414
2 changed files with 11 additions and 1 deletions

View File

@ -600,7 +600,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
type = Variables::reference;
else if (i->nameToken()->previous()->str() == "*" && i->nameToken()->strAt(-2) == "*")
type = Variables::pointerPointer;
else if (i->nameToken()->previous()->str() == "*" || i->nameToken()->strAt(-2) == "*")
else if (i->nameToken()->previous()->str() == "*" || Token::Match(i->nameToken()->tokAt(-2), "* %type%"))
type = Variables::pointer;
else if (i->typeEndToken()->isStandardType() || isRecordTypeWithoutSideEffects(*i) || Token::simpleMatch(i->nameToken()->tokAt(-3), "std :: string"))
type = Variables::standard;

View File

@ -124,6 +124,7 @@ private:
TEST_CASE(localvarFor); // for ( ; var; )
TEST_CASE(localvarShift1); // 1 >> var
TEST_CASE(localvarShift2); // x = x >> 1
TEST_CASE(localvarShift3); // x << y
TEST_CASE(localvarCast);
TEST_CASE(localvarClass);
TEST_CASE(localvarUnused);
@ -2542,6 +2543,15 @@ private:
ASSERT_EQUALS("", errout.str());
}
void localvarShift3() { // #3509
functionVariableUsage("int foo()\n"
"{\n"
" QList<int *> ints;\n"
" ints << 1;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void localvarCast() {
functionVariableUsage("int foo()\n"
"{\n"