typedef: fixed problem with 'typedef int pread_f(int);'. ticket: #2348
This commit is contained in:
parent
e82b1f8946
commit
137d0e2ba7
|
@ -1438,6 +1438,8 @@ void Tokenizer::simplifyTypedef()
|
|||
{
|
||||
if (Token::Match(tok2->next(), "( * %type% ) ("))
|
||||
tok2 = tok2->tokAt(5)->link();
|
||||
else if (Token::Match(tok2->next(), "* ( * %type% ) ("))
|
||||
tok2 = tok2->tokAt(6)->link();
|
||||
else
|
||||
{
|
||||
if (tok2->next()->str() == "(")
|
||||
|
@ -6618,6 +6620,7 @@ bool Tokenizer::simplifyCalculations()
|
|||
// Remove parentheses around variable..
|
||||
// keep parentheses here: dynamic_cast<Fred *>(p);
|
||||
// keep parentheses here: A operator * (int);
|
||||
// keep parentheses here: int ( * ( * f ) ( ... ) ) (int) ;
|
||||
// keep parentheses here: int ( * * ( * compilerHookVector ) (void) ) ( ) ;
|
||||
// keep parentheses here: operator new [] (size_t);
|
||||
// keep parentheses here: Functor()(a ... )
|
||||
|
@ -6627,6 +6630,7 @@ bool Tokenizer::simplifyCalculations()
|
|||
tok->str() != "]" &&
|
||||
!Token::simpleMatch(tok->previous(), "operator") &&
|
||||
!Token::simpleMatch(tok->previous(), "* )") &&
|
||||
!Token::simpleMatch(tok->previous(), ") )") &&
|
||||
!Token::Match(tok->tokAt(-2), "* %var% )") &&
|
||||
!Token::Match(tok->tokAt(-2), "%type% ( ) ( %var%")
|
||||
)
|
||||
|
|
|
@ -226,6 +226,8 @@ private:
|
|||
TEST_CASE(simplifyTypedef66); // ticket #2341
|
||||
TEST_CASE(simplifyTypedef67); // ticket #2354
|
||||
TEST_CASE(simplifyTypedef68); // ticket #2355
|
||||
TEST_CASE(simplifyTypedef69); // ticket #2348
|
||||
TEST_CASE(simplifyTypedef70); // ticket #2348
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -4663,6 +4665,21 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef70() // ticket #2348
|
||||
{
|
||||
const char code[] = "typedef int pread_f ( int ) ;\n"
|
||||
"pread_f *(*test_func)(char *filename);\n";
|
||||
|
||||
|
||||
|
||||
|
||||
const std::string expected = "; "
|
||||
"int ( * ( * test_func ) ( char * filename ) ) ( int ) ;";
|
||||
|
||||
ASSERT_EQUALS(expected, sizeof_(code));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue