From 531d0fa68595e468facffdb458ab68d45b1cfcf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 20 Nov 2009 20:42:28 +0100 Subject: [PATCH] Fixed #965 (Division by zero false positive with nested macros) --- lib/tokenize.cpp | 2 +- test/testsimplifytokens.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 493375a9f..93ffbd5b7 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3714,7 +3714,7 @@ bool Tokenizer::simplifyCalculations() continue; // + and - are calculated after * - if (Token::Match(tok->next(), "[+-]")) + if (Token::Match(tok->next(), "[+-/]")) { if (tok->previous()->str() == "*") continue; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 4f46493b3..c4cd724d2 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1758,6 +1758,7 @@ private: ASSERT_EQUALS("x = 1 + 2 * y ;", tok("x=1+2*y;")); ASSERT_EQUALS("x = 7 ;", tok("x=1+2*3;")); ASSERT_EQUALS("x = 47185 ;", tok("x=(65536*72/100);")); + ASSERT_EQUALS("x = 900 ;", tok("x = 1500000 / ((145000 - 55000) * 1000 / 54000);")); }