diff --git a/src/tokenize.cpp b/src/tokenize.cpp index d7bb3780c..2f851bb19 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -3259,7 +3259,7 @@ bool Tokenizer::simplifyKnownVariables() } // Variable is used in calculation.. - if (Token::Match(tok3, "[=+-*/[] %varid% [+-*/;]]", varid) || + if (Token::Match(tok3, "[=+-*/[] %varid% [?+-*/;]]", varid) || Token::Match(tok3, "[=+-*/[] %varid% <<", varid) || Token::Match(tok3, "<< %varid% [+-*/;]]", varid)) { diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 8876a6707..869fb876a 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1563,6 +1563,15 @@ private: const char code[] = "( true ? abc . a : abc . b )"; ASSERT_EQUALS("( abc . a )", tok(code)); } + + { + const char code[] = "void f()\n" + "{\n" + " bool x = false;\n" + " int b = x ? 44 : 3;\n" + "}\n"; + ASSERT_EQUALS("void f ( ) { bool x ; x = false ; int b ; b = 3 ; }", tok(code)); + } } void calculations()