Fix ticket #344 (Tokenizer crash in Windows)
http://apps.sourceforge.net/trac/cppcheck/ticket/344
This commit is contained in:
parent
aba7518aeb
commit
3fe1b50e60
|
@ -2458,15 +2458,6 @@ bool Tokenizer::simplifyRedundantParanthesis()
|
|||
tok->deleteNext();
|
||||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "( %bool% ) )") ||
|
||||
Token::Match(tok, "( %num% ) )"))
|
||||
{
|
||||
tok = tok->next();
|
||||
tok->deleteNext();
|
||||
tok->previous()->deleteThis();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1652,6 +1652,25 @@ private:
|
|||
ostr << " " << tok->str();
|
||||
ASSERT_EQUALS(std::string(" void foo ( ) { { } }"), ostr.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "void foo()\n"
|
||||
"{\n"
|
||||
" if( g(10)){}\n"
|
||||
"}";
|
||||
|
||||
// tokenize..
|
||||
Tokenizer tokenizer;
|
||||
std::istringstream istr(code);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
|
||||
tokenizer.simplifyTokenList();
|
||||
|
||||
std::ostringstream ostr;
|
||||
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
|
||||
ostr << " " << tok->str();
|
||||
ASSERT_EQUALS(std::string(" void foo ( ) { if ( g ( 10 ) ) { } }"), ostr.str());
|
||||
}
|
||||
}
|
||||
|
||||
void simplify_numeric_condition()
|
||||
|
|
Loading…
Reference in New Issue