TemplateSimplifier: Fixed bug in simplifyCalculations. Now template58 test case does not throw InternalError

This commit is contained in:
Daniel Marjamäki 2017-06-08 00:49:46 +02:00
parent d2e7df2c04
commit cb48e63f92
2 changed files with 10 additions and 5 deletions

View File

@ -1137,11 +1137,10 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
}
if (Token::Match(tok->tokAt(-2), "%any% * 1") || Token::Match(tok->previous(), "%any% 1 *")) {
if (tok->isNumber())
tok = tok->previous();
tok = tok->previous();
tok->deleteNext();
tok->deleteNext();
if (tok->str() == "*")
tok = tok->previous();
tok->deleteNext(2);
ret = true;
}

View File

@ -1056,7 +1056,13 @@ private:
"void foo() {\n"
" TestArithmetic<int>();\n"
"}";
ASSERT_THROW(tok(code), InternalError);
const char exp[] = "void foo ( ) {"
" TestArithmetic < int > ( ) ; "
"} "
"void TestArithmetic < int > ( ) {"
" x ( CheckedNumeric < int > ( ) ) ; "
"}";
ASSERT_EQUALS(exp, tok(code));
}
void template_enum() {