Skip to content

Commit f82c4b8

Browse files
committed
Fix #14439
1 parent 15248cc commit f82c4b8

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lib/tokenize.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,13 +4300,14 @@ void VariableMap::addVariable(const std::string& varname, bool globalNamespace)
43004300
/**
43014301
* @throws Token* thrown when closing brackets are missing
43024302
*/
4303-
static bool setVarIdParseDeclaration(Token*& tok, const VariableMap& variableMap, bool executableScope, Standards::cstd_t cStandard)
4303+
static bool setVarIdParseDeclaration(Token*& tok, const VariableMap& variableMap, bool executableScope, Standards::cstd_t cStandard, Token*& funcPtrArgs)
43044304
{
43054305
const Token* const tok1 = tok;
43064306
Token* tok2 = tok;
43074307
if (!tok2->isName() || (tok2->tokType() != Token::eType && tok2->tokType() != Token::eName && tok2->tokType() != Token::eKeyword))
43084308
return false;
43094309

4310+
funcPtrArgs = nullptr;
43104311
nonneg int typeCount = 0;
43114312
nonneg int singleNameCount = 0;
43124313
bool hasstruct = false; // Is there a "struct" or "class"?
@@ -4373,6 +4374,7 @@ static bool setVarIdParseDeclaration(Token*& tok, const VariableMap& variableMap
43734374
if (tok3->str() == ",")
43744375
return false;
43754376
}
4377+
funcPtrArgs = tok2->link()->next();
43764378
bracket = true; // Skip: Seems to be valid pointer to array or function pointer
43774379
} else if (singleNameCount >= 1 && Token::Match(tok2, "( * %name% [") && Token::Match(tok2->linkAt(3), "] ) [;,]") && !variableMap.map(false).count(tok2->strAt(2))) {
43784380
bracket = true;
@@ -4680,9 +4682,15 @@ void Tokenizer::setVarIdPass1()
46804682
const Token *functionDeclEndToken = nullptr;
46814683
bool initlist = false;
46824684
bool inlineFunction = false;
4685+
Token *funcPtrArgs = nullptr;
46834686
for (Token *tok = list.front(); tok; tok = tok->next()) {
46844687
if (tok->isOp())
46854688
continue;
4689+
if (tok == funcPtrArgs) {
4690+
tok = funcPtrArgs->link();
4691+
funcPtrArgs = nullptr;
4692+
continue;
4693+
}
46864694
if (cpp && Token::simpleMatch(tok, "template <")) {
46874695
Token* closingBracket = tok->next()->findClosingBracket();
46884696
if (closingBracket)
@@ -4855,7 +4863,7 @@ void Tokenizer::setVarIdPass1()
48554863
}
48564864

48574865
try { /* Ticket #8151 */
4858-
decl = setVarIdParseDeclaration(tok2, variableMap, scopeStack.top().isExecutable, mSettings.standards.c);
4866+
decl = setVarIdParseDeclaration(tok2, variableMap, scopeStack.top().isExecutable, mSettings.standards.c, funcPtrArgs);
48594867
} catch (const Token * errTok) {
48604868
syntaxError(errTok);
48614869
}

0 commit comments

Comments
 (0)