From 406483b6183cde8e2f0661960a28f9279a5c060d Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Thu, 20 Sep 2012 21:06:28 +0200 Subject: [PATCH] Fixed valgrind error in #3953 , but there's still the bad enum problem. --- lib/templatesimplifier.cpp | 9 ++++++--- test/testtokenize.cpp | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index bbb1ded46..54a06d7d8 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -844,9 +844,12 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens) tok->deleteNext(); tok->deleteThis(); ret = true; - } else if (Token::Match(tok->previous(), "[=[(,] 0 * %any% ,|]|)|;|=|%op%") || - Token::Match(tok->previous(), "return|case 0 * %any% ,|:|;|=|%op%") || - Token::Match(tok->previous(), "return|case 0 && %any% ,|:|;|=|%op%")) { + } else if (Token::Match(tok->previous(), "[=[(,] 0 * %var% ,|]|)|;|=|%op%") || + Token::Match(tok->previous(), "[=[(,] 0 * %num% ,|]|)|;|=|%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(); if (tok->next()->str() == "(") Token::eraseTokens(tok, tok->next()->link()); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 82dd38b92..3a97f6955 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6638,6 +6638,9 @@ private: // ticket #3964 - simplify numeric calculations in tokenization 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() {