File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -738,7 +738,9 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
738738 if (type == Variables::none || isPartOfClassStructUnion (i->typeStartToken ()))
739739 continue ;
740740 const Token* defValTok = i->nameToken ()->next ();
741- if (Token::Match (i->nameToken ()->previous (), " * %var% ) (" )) // function pointer. Jump behind parameter list.
741+ while (defValTok && defValTok->str () == " [" )
742+ defValTok = defValTok->link ()->next ();
743+ if (Token::Match (defValTok, " ) (" ))
742744 defValTok = defValTok->linkAt (1 )->next ();
743745 for (; defValTok; defValTok = defValTok->next ()) {
744746 if (defValTok->str () == " [" )
Original file line number Diff line number Diff line change @@ -7034,6 +7034,12 @@ class TestUnusedVar : public TestFixture {
70347034 " funcPtr();\n "
70357035 " }" );
70367036 ASSERT_EQUALS (" " , errout_str ());
7037+
7038+ functionVariableUsage (" int main() {\n "
7039+ " void (*const funcPtr[])(void) = {x};\n "
7040+ " funcPtr[0]();\n "
7041+ " }" );
7042+ ASSERT_EQUALS (" " , errout_str ());
70377043 }
70387044
70397045 void localvarAddr () { // #7747
You can’t perform that action at this time.
0 commit comments