From cd4e355f17c0622e5b88bd3988d7bae2049900a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 6 Dec 2009 10:58:27 +0100 Subject: [PATCH] Fixed #1052 (Internal error for 'int vals[] = { 0x13, 1?0x01:0x00 };') --- lib/tokenize.cpp | 4 ++-- test/testsimplifytokens.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) 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()