Improved typedef simplification of function pointers
This commit is contained in:
parent
a6e81c2ee7
commit
e9e64033e7
|
@ -680,8 +680,8 @@ void Tokenizer::simplifyTypedef()
|
|||
tok2 = tok2->next();
|
||||
|
||||
// skip over typedef parameter
|
||||
while (!Token::Match(tok2->next(), "=|{|;"))
|
||||
tok2 = tok2->next();
|
||||
if (tok2->next()->str() == "(")
|
||||
tok2 = tok2->next()->link();
|
||||
|
||||
tok2->insertToken(")");
|
||||
tok2 = tok2->next();
|
||||
|
|
|
@ -157,6 +157,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef20);
|
||||
TEST_CASE(simplifyTypedef21);
|
||||
TEST_CASE(simplifyTypedef22);
|
||||
TEST_CASE(simplifyTypedef23);
|
||||
TEST_CASE(reverseArraySyntax)
|
||||
TEST_CASE(simplify_numeric_condition)
|
||||
|
||||
|
@ -2710,6 +2711,20 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void simplifyTypedef23()
|
||||
{
|
||||
const char code[] = "typedef bool (*Callback) (int i);\n"
|
||||
"void addCallback(Callback callback) { }\n"
|
||||
"void addCallback1(Callback callback, int j) { }";
|
||||
|
||||
const char expected[] =
|
||||
"; "
|
||||
"void addCallback ( bool ( * callback ) ( int i ) ) { } "
|
||||
"void addCallback1 ( bool ( * callback ) ( int i ) , int j ) { }";
|
||||
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
|
||||
void reverseArraySyntax()
|
||||
{
|
||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||
|
|
Loading…
Reference in New Issue