typedef: fix typedef simplification. ticket: #2348
This commit is contained in:
parent
bdf0cb7115
commit
e82b1f8946
|
@ -6618,6 +6618,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 ( * * ( * compilerHookVector ) (void) ) ( ) ;
|
||||
// keep parentheses here: operator new [] (size_t);
|
||||
// keep parentheses here: Functor()(a ... )
|
||||
if (Token::Match(tok->next(), "( %var% ) [;),+-*/><]]") &&
|
||||
|
@ -6626,6 +6627,7 @@ bool Tokenizer::simplifyCalculations()
|
|||
tok->str() != "]" &&
|
||||
!Token::simpleMatch(tok->previous(), "operator") &&
|
||||
!Token::simpleMatch(tok->previous(), "* )") &&
|
||||
!Token::Match(tok->tokAt(-2), "* %var% )") &&
|
||||
!Token::Match(tok->tokAt(-2), "%type% ( ) ( %var%")
|
||||
)
|
||||
{
|
||||
|
|
|
@ -4645,6 +4645,24 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef69() // ticket #2348
|
||||
{
|
||||
const char code[] = "typedef int (*CompilerHook)();\n"
|
||||
"typedef struct VirtualMachine \n"
|
||||
"{\n"
|
||||
" CompilerHook *(*compilerHookVector)(void);\n"
|
||||
"}VirtualMachine;\n";
|
||||
|
||||
const std::string expected = "; "
|
||||
"struct VirtualMachine "
|
||||
"{ "
|
||||
"int ( * * ( * compilerHookVector ) ( void ) ) ( ) ; "
|
||||
"} ;";
|
||||
|
||||
ASSERT_EQUALS(expected, sizeof_(code));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue