Fixed typedef simplification for array of function pointers

This commit is contained in:
Daniel Marjamäki 2020-04-13 16:28:01 +02:00
parent 9ccf068393
commit 98be091d80
2 changed files with 6 additions and 3 deletions

View File

@ -1313,7 +1313,7 @@ void Tokenizer::simplifyTypedef()
if (funcStart && funcEnd) {
tok2->insertToken("(");
tok2 = tok2->next();
Token *tok3 = tok2;
Token *paren = tok2;
tok2 = TokenList::copyTokens(tok2, funcStart, funcEnd);
if (!inCast)
@ -1322,9 +1322,12 @@ void Tokenizer::simplifyTypedef()
if (!tok2)
break;
while (Token::Match(tok2, "%name%|] ["))
tok2 = tok2->linkAt(1);
tok2->insertToken(")");
tok2 = tok2->next();
Token::createMutualLinks(tok2, tok3);
Token::createMutualLinks(tok2, paren);
tok2 = TokenList::copyTokens(tok2, argStart, argEnd);

View File

@ -5023,7 +5023,7 @@ private:
"PF pfs[] = { &f1, &f1 };";
const char expected[] = "void f1 ( ) { } "
"void ( * pf ) ( ) ; pf = & f1 ; "
"void ( * pfs ) ( ) [ ] = { & f1 , & f1 } ;"; // TODO : Is [] placed correctly?
"void ( * pfs [ ] ) ( ) = { & f1 , & f1 } ;";
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}