fix #2651 function typedef with extra ()s
This commit is contained in:
parent
fa868e44ae
commit
ba0b3e6451
|
@ -1234,10 +1234,17 @@ void Tokenizer::simplifyTypedef()
|
|||
}
|
||||
|
||||
// function: typedef ... ( .... type )( ... );
|
||||
else if (tok->tokAt(offset)->str() == "(" &&
|
||||
Token::Match(tok->tokAt(offset)->link()->previous(), "%type% ) (") &&
|
||||
Token::Match(tok->tokAt(offset)->link()->next()->link(), ") const|volatile|;"))
|
||||
// typedef ... (( .... type )( ... ));
|
||||
else if ((tok->tokAt(offset)->str() == "(" &&
|
||||
Token::Match(tok->tokAt(offset)->link()->previous(), "%type% ) (") &&
|
||||
Token::Match(tok->tokAt(offset)->link()->next()->link(), ") const|volatile|;")) ||
|
||||
(Token::simpleMatch(tok->tokAt(offset), "( (") &&
|
||||
Token::Match(tok->tokAt(offset + 1)->link()->previous(), "%type% ) (") &&
|
||||
Token::Match(tok->tokAt(offset + 1)->link()->next()->link(), ") const|volatile| )")))
|
||||
{
|
||||
if (tok->strAt(offset + 1) == "(")
|
||||
offset++;
|
||||
|
||||
funcStart = tok->tokAt(offset + 1);
|
||||
funcEnd = tok->tokAt(offset)->link()->tokAt(-2);
|
||||
typeName = tok->tokAt(offset)->link()->previous();
|
||||
|
@ -1256,6 +1263,8 @@ void Tokenizer::simplifyTypedef()
|
|||
}
|
||||
tok = specEnd->next();
|
||||
}
|
||||
if (tok->str() == ")")
|
||||
tok = tok->next();
|
||||
}
|
||||
|
||||
else if (Token::Match(tok->tokAt(offset), "( %type% ("))
|
||||
|
|
|
@ -246,6 +246,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef82); // ticket #2403
|
||||
TEST_CASE(simplifyTypedef83); // ticket #2620
|
||||
TEST_CASE(simplifyTypedef84); // ticket #2630
|
||||
TEST_CASE(simplifyTypedef85); // ticket #2651
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -4986,6 +4987,15 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef85() // ticket #2651
|
||||
{
|
||||
const char code[] = "typedef FOO ((BAR)(void, int, const int, int*));\n";
|
||||
const char expected[] = ";";
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS(expected, sizeof_(code));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue