From 7acb04b44c8a46e43528ce53632420b3715b703e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 9 Sep 2012 16:22:39 +0200 Subject: [PATCH] Tokenizer: improved simplification of numeric calculations --- lib/templatesimplifier.cpp | 2 +- test/testsimplifytokens.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 7d769d6da..e3e6e7511 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -681,7 +681,7 @@ void TemplateSimplifier::simplifyTemplatesExpandTemplate( static bool isLowerThanOr(const Token* lower) { - return lower->isAssignmentOp() || Token::Match(lower, ";|(|[|]|)|,|?|:|%oror%|&&|return|throw|case"); + return lower->isAssignmentOp() || Token::Match(lower, "}|;|(|[|]|)|,|?|:|%oror%|&&|return|throw|case"); } static bool isLowerThanXor(const Token* lower) { diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 47c320b69..63bc18d22 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -7151,7 +7151,7 @@ private: void enum29() { // #3747 - bitwise or value const char code[] = "enum { x=1, y=x|2 }; i = (3==y);"; - ASSERT_EQUALS("i = 3 == 1 | 2 ;", checkSimplifyEnum(code)); + ASSERT_EQUALS("i = 3 == 3 ;", checkSimplifyEnum(code)); } void enum30() { // #3852 - false positive @@ -7181,7 +7181,7 @@ private: void enum32() { // #3998 - wrong enum simplification => access violation const char code[] = "enum { x=(32), y=x, z }; { a, z }"; - ASSERT_EQUALS("{ a , 32 + 1 }", checkSimplifyEnum(code)); + ASSERT_EQUALS("{ a , 33 }", checkSimplifyEnum(code)); } void enum33() { // #4015 - segmentation fault