Fixed valgrind error in #3953 , but there's still the bad enum problem.

This commit is contained in:
Edoardo Prezioso 2012-09-20 21:06:28 +02:00
parent de8e592d00
commit 406483b618
2 changed files with 9 additions and 3 deletions

View File

@ -844,9 +844,12 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
tok->deleteNext(); tok->deleteNext();
tok->deleteThis(); tok->deleteThis();
ret = true; ret = true;
} else if (Token::Match(tok->previous(), "[=[(,] 0 * %any% ,|]|)|;|=|%op%") || } else if (Token::Match(tok->previous(), "[=[(,] 0 * %var% ,|]|)|;|=|%op%") ||
Token::Match(tok->previous(), "return|case 0 * %any% ,|:|;|=|%op%") || Token::Match(tok->previous(), "[=[(,] 0 * %num% ,|]|)|;|=|%op%") ||
Token::Match(tok->previous(), "return|case 0 && %any% ,|:|;|=|%op%")) { Token::Match(tok->previous(), "[=[(,] 0 * ( ,|]|)|;|=|%op%") ||
Token::Match(tok->previous(), "return|case 0 *|&& %var% ,|:|;|=|%op%") ||
Token::Match(tok->previous(), "return|case 0 *|&& %num% ,|:|;|=|%op%") ||
Token::Match(tok->previous(), "return|case 0 *|&& ( ,|:|;|=|%op%")) {
tok->deleteNext(); tok->deleteNext();
if (tok->next()->str() == "(") if (tok->next()->str() == "(")
Token::eraseTokens(tok, tok->next()->link()); Token::eraseTokens(tok, tok->next()->link());

View File

@ -6638,6 +6638,9 @@ private:
// ticket #3964 - simplify numeric calculations in tokenization // ticket #3964 - simplify numeric calculations in tokenization
ASSERT_EQUALS("char a [ 10 ] ;", tokenizeAndStringify("char a[9+1];")); ASSERT_EQUALS("char a [ 10 ] ;", tokenizeAndStringify("char a[9+1];"));
// #3953 (valgrind errors on garbage code)
ASSERT_EQUALS("void f ( 0 * ) ;", tokenizeAndStringify("void f ( 0 * ) ;"));
} }
void simplifyCompoundAssignment() { void simplifyCompoundAssignment() {