diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 33a59d7bda3..26ba64bd6ef 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5017,8 +5017,8 @@ void Tokenizer::setVarIdPass1() // there are tokens which can't appear at the begin of a function declaration such as "return" const bool isNotstartKeyword = start->next() && notstart.find(start->strAt(1)) != notstart.end(); - // now check if it is a function declaration - if (Token::Match(start, "[;{}] %type% %name%|*") && par && Token::simpleMatch(end, ") ;") && !isNotstartKeyword) { + // now check if it is a function (pointer) declaration + if ((Token::simpleMatch(start, ") (") || Token::Match(start, "[;{}] %type% %name%|*")) && par && Token::Match(end, ") [;=]") && !isNotstartKeyword) { // function declaration => don't set varid tok = end; continue; diff --git a/test/testvarid.cpp b/test/testvarid.cpp index de8a58cfa61..32bff9c5724 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -3497,6 +3497,16 @@ class TestVarID : public TestFixture { const char code3[] = "void f (void (*g) (int i, IN int n)) {}\n"; ASSERT_EQUALS("1: void f ( void ( * g@1 ) ( int , IN int ) ) { }\n", tokenize(code3)); + + const char code4[] = "void f() {\n" // #14439 + " int* p;\n" + " void (*a[1])(int* p) = { 0 };\n" + "}\n"; + ASSERT_EQUALS("1: void f ( ) {\n" + "2: int * p@1 ;\n" + "3: void ( * a@2 [ 1 ] ) ( int * p ) = { 0 } ;\n" + "4: }\n", + tokenize(code4)); } void varid_alignas() {