From 2722f53edd3734db577cf63bc2b9550dd3ac892d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 8 Sep 2012 10:15:37 +0200 Subject: [PATCH] Fixed #4142 (false positive (error) Uninitialized variable: b) --- lib/tokenize.cpp | 2 ++ test/testsimplifytokens.cpp | 9 ++++----- test/testtokenize.cpp | 4 +--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 8bf5bf348..256adf93d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1971,6 +1971,8 @@ bool Tokenizer::tokenize(std::istream &code, // Remove redundant parentheses simplifyRedundantParenthesis(); + for (Token *tok = list.front(); tok; tok = tok->next()) + while (TemplateSimplifier::simplifyNumericCalculations(tok)); // Handle templates.. simplifyTemplates(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 30cb7e46c..0a6df09cc 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -6840,11 +6840,10 @@ private: const char expected[] = "int sum ; sum = " "sizeof ( int ) + " "1 + sizeof ( int ) + " - "1 + sizeof ( int ) + 100 + " - "1 + sizeof ( int ) + 100 + 1 + " - "1 + sizeof ( int ) + 100 + 2 + " - "90 + " - "91 ;"; + "1 + sizeof ( int ) + 101 + " // 101 = 100 + 1 + "sizeof ( int ) + 102 + " // 102 = 100 + 1 + 1 + "sizeof ( int ) + 283 " // 283 = 100+2+90+91 + ";"; ASSERT_EQUALS(expected, tok(code, false)); ASSERT_EQUALS("int sum ; sum = 508 ;", tok(code, true)); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 9b753e894..234749350 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4573,9 +4573,7 @@ private: void removeParentheses15() { ASSERT_EQUALS("a = b ? c : 123 ;", tokenizeAndStringify("a = b ? c : (123);", false)); - TODO_ASSERT_EQUALS("a = b ? c : 579 ;", - "a = b ? c : 123 + 456 ;", - tokenizeAndStringify("a = b ? c : ((123)+(456));", false)); + ASSERT_EQUALS("a = b ? c : 579 ;", tokenizeAndStringify("a = b ? c : ((123)+(456));", false)); } void tokenize_double() {