diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 6b08fbfdd..d812d66f8 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2717,12 +2717,12 @@ bool Tokenizer::simplifyQuestionMark() break; } - else if (end->str() == "(") + else if (Token::Match(end, "[({[]")) { ++ind; } - else if (end->str() == ")") + else if (Token::Match(end, "[)}]]")) { --ind; if (ind < 0) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index ae31e9c37..6eaf91c9b 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1810,6 +1810,16 @@ private: "}\n"; ASSERT_EQUALS("void f ( ) { bool x ; x = false ; int b ; b = 3 ; }", tok(code)); } + + { + const char code[] = "int vals[] = { 0x13, 1?0x01:0x00 };"; + ASSERT_EQUALS("int * vals ; vals = { 19 , 1 } ;", tok(code)); + } + + { + const char code[] = "int vals[] = { 0x13, 0?0x01:0x00 };"; + ASSERT_EQUALS("int * vals ; vals = { 19 , 0 } ;", tok(code)); + } } void calculations()