Skip to content

Commit 8be401d

Browse files
Update tokenize.cpp
1 parent 08307a9 commit 8be401d

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

lib/tokenize.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,6 +3211,8 @@ bool Tokenizer::simplifyUsing()
32113211
}
32123212

32133213
Token * arrayStart = nullptr;
3214+
Token * fpArgList = nullptr;
3215+
Token * fpQual = nullptr;
32143216

32153217
// parse the type
32163218
Token *type = start;
@@ -3310,6 +3312,15 @@ bool Tokenizer::simplifyUsing()
33103312
} while (type && type->str() == "[");
33113313
}
33123314

3315+
// check for function pointer
3316+
if (type && type->str() == "(") {
3317+
if (Token::simpleMatch(type->link(), ") (")) {
3318+
fpArgList = type->link()->next();
3319+
fpQual = type;
3320+
type = type->link()->next()->link()->next();
3321+
}
3322+
}
3323+
33133324
// make sure we are in a good state
33143325
if (!tok1 || !tok1->next())
33153326
break; // bail
@@ -3325,6 +3336,14 @@ bool Tokenizer::simplifyUsing()
33253336
tok1->deleteThis();
33263337
substitute = true;
33273338
}
3339+
// function pointer
3340+
} else if (fpArgList && fpQual && Token::Match(tok1->next(), "%name%")) {
3341+
TokenList::copyTokens(tok1->next(), fpArgList, usingEnd->previous());
3342+
Token* const copyEnd = TokenList::copyTokens(tok1, start, fpQual->link()->previous());
3343+
tok1->deleteThis();
3344+
Token* const rightPar = copyEnd->next()->insertToken(")");
3345+
Token::createMutualLinks(tok1->next(), rightPar);
3346+
substitute = true;
33283347
} else {
33293348
// add some qualification back if needed
33303349
std::string removed1 = std::move(removed);

0 commit comments

Comments
 (0)