Fixed #620 (Tokenizer: replace "and" by "&&")
http://sourceforge.net/apps/trac/cppcheck/ticket/620
This commit is contained in:
parent
840bbcfcbb
commit
eb05cf904d
|
@ -1504,6 +1504,13 @@ void Tokenizer::simplifyTokenList()
|
|||
}
|
||||
}
|
||||
|
||||
// Replace "and" with "&&"
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (tok->str() == "and")
|
||||
tok->str("&&");
|
||||
}
|
||||
|
||||
simplifyCasts();
|
||||
|
||||
// Simplify simple calculations..
|
||||
|
|
|
@ -91,6 +91,10 @@ private:
|
|||
|
||||
// Simplify "not" to "!" (#345)
|
||||
TEST_CASE(not1);
|
||||
|
||||
// Simplify "and" to "&&" (#620)
|
||||
TEST_CASE(and1);
|
||||
|
||||
TEST_CASE(comma_keyword);
|
||||
TEST_CASE(remove_comma);
|
||||
|
||||
|
@ -1030,6 +1034,15 @@ private:
|
|||
ASSERT_EQUALS("void foo ( not i )", simplifyNot("void foo ( not i )"));
|
||||
}
|
||||
|
||||
void and1()
|
||||
{
|
||||
ASSERT_EQUALS(" if ( p && q )",
|
||||
sizeof_(" if (p and q)"));
|
||||
|
||||
ASSERT_EQUALS(" return operator == ( a ) && radius == 4 ;",
|
||||
sizeof_(" return operator==(a) and radius == 4;"));
|
||||
}
|
||||
|
||||
void comma_keyword()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue