Fixed #961 (Tokenizer: call simplifyCasts() before removing "unsigned" keyword)
http://sourceforge.net/apps/trac/cppcheck/ticket/961
This commit is contained in:
parent
3097444438
commit
11cb7b4710
|
@ -1853,6 +1853,9 @@ bool Tokenizer::simplifyTokenList()
|
|||
// Convert e.g. atol("0") into 0
|
||||
simplifyMathFunctions();
|
||||
|
||||
// simplify casts before removing "unsigned" keywords (to fix #961)
|
||||
simplifyCasts();
|
||||
|
||||
// Remove unwanted keywords
|
||||
static const char * const unwantedWords[] = { "unsigned", "unlikely", "likely" };
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
|
@ -2004,7 +2007,6 @@ bool Tokenizer::simplifyTokenList()
|
|||
}
|
||||
|
||||
simplifyLogicalOperators();
|
||||
simplifyCasts();
|
||||
|
||||
// Simplify simple calculations..
|
||||
while (simplifyCalculations())
|
||||
|
|
|
@ -47,6 +47,7 @@ private:
|
|||
|
||||
TEST_CASE(removeCast1);
|
||||
TEST_CASE(removeCast2);
|
||||
TEST_CASE(removeCast3);
|
||||
|
||||
TEST_CASE(inlineasm);
|
||||
|
||||
|
@ -281,6 +282,14 @@ private:
|
|||
ASSERT_EQUALS(" t = ( & p ) ;", ostr.str());
|
||||
}
|
||||
|
||||
void removeCast3()
|
||||
{
|
||||
// ticket #961
|
||||
const char code[] = "assert (iplen >= (unsigned) ipv4->ip_hl * 4 + 20);";
|
||||
const char expected[] = "assert ( iplen >= ipv4 . ip_hl * 4 + 20 ) ;";
|
||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true));
|
||||
}
|
||||
|
||||
|
||||
void inlineasm()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue