diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index f28b60ec5..99207f67a 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -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; diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 1efa4774d..0f4f66a91 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -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 ints;\n" + " ints << 1;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void localvarCast() { functionVariableUsage("int foo()\n" "{\n"