diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 90a22b877..9c77aa60f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9350,12 +9350,12 @@ void Tokenizer::simplifyMathExpressions() tok->str("0"); } - if (Token::Match(tok,"pow ( sin ( %var% ) , 2 ) + pow ( cos ( %var% ) , 2 )")) { + if (Token::Match(tok,"pow ( sin ( %any% ) , 2 ) + pow ( cos ( %any% ) , 2 )") && tok->strAt(4) == tok->strAt(14)) { tok->deleteNext(18); tok->str("1"); } - if (Token::Match(tok,"pow ( sinh ( %var% ) , 2 ) - pow ( cosh ( %var% ) , 2 )")) { + if (Token::Match(tok,"pow ( sinh ( %any% ) , 2 ) - pow ( cosh ( %any% ) , 2 )") && tok->strAt(4) == tok->strAt(14)) { tok->deleteNext(18); tok->str("-1"); } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7350b0a71..9a0189c35 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7714,32 +7714,38 @@ private: } void simplifyMathExpressions() {//#1620 - const char *code1 ="void foo() {\n" - "std::cout<