Fixed #1298 ((error) ### Internal error in Cppcheck. Please report it. (typedef in fun proto))
This commit is contained in:
parent
1552c0f7f2
commit
13ca2510cc
|
@ -682,6 +682,8 @@ void Tokenizer::simplifyTypedef()
|
|||
tok2 = tok2->next();
|
||||
|
||||
if (!inCast)
|
||||
{
|
||||
if (tok2->next()->str() != ")" && tok2->next()->str() != ",")
|
||||
{
|
||||
tok2 = tok2->next();
|
||||
|
||||
|
@ -689,6 +691,7 @@ void Tokenizer::simplifyTypedef()
|
|||
if (tok2->next()->str() == "(")
|
||||
tok2 = tok2->next()->link();
|
||||
}
|
||||
}
|
||||
|
||||
tok2->insertToken(")");
|
||||
tok2 = tok2->next();
|
||||
|
@ -949,7 +952,7 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[])
|
|||
removeExceptionSpecifications(_tokens);
|
||||
|
||||
// simplify function pointers
|
||||
simplifyFunctionPointers();
|
||||
// simplifyFunctionPointers();
|
||||
|
||||
setVarId();
|
||||
if (!validate())
|
||||
|
|
|
@ -160,6 +160,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef22);
|
||||
TEST_CASE(simplifyTypedef23);
|
||||
TEST_CASE(simplifyTypedef24);
|
||||
TEST_CASE(simplifyTypedef25);
|
||||
TEST_CASE(reverseArraySyntax)
|
||||
TEST_CASE(simplify_numeric_condition)
|
||||
|
||||
|
@ -2815,6 +2816,40 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void simplifyTypedef25()
|
||||
{
|
||||
{
|
||||
// ticket #1298
|
||||
const char code[] = "typedef void (*fill_names_f) (const char *);\n"
|
||||
"struct vfs_class {\n"
|
||||
" void (*fill_names) (struct vfs_class *me, fill_names_f);\n"
|
||||
"}";
|
||||
|
||||
const char expected[] =
|
||||
"; "
|
||||
"struct vfs_class { "
|
||||
"void ( * fill_names ) ( struct vfs_class * me , void ( * ) ( const char * ) ) ; "
|
||||
"}";
|
||||
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "typedef void (*fill_names_f) (const char *);\n"
|
||||
"struct vfs_class {\n"
|
||||
" void (*fill_names) (fill_names_f, struct vfs_class *me);\n"
|
||||
"}";
|
||||
|
||||
const char expected[] =
|
||||
"; "
|
||||
"struct vfs_class { "
|
||||
"void ( * fill_names ) ( void ( * ) ( const char * ) , struct vfs_class * me ) ; "
|
||||
"}";
|
||||
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
}
|
||||
}
|
||||
|
||||
void reverseArraySyntax()
|
||||
{
|
||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||
|
|
Loading…
Reference in New Issue