Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading