From 49198f52c434637a502a5d0c7c905cdf038e3b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 7 Jul 2012 15:34:26 +0200 Subject: [PATCH] Fixed #3934 (False positive for logical conjunction with enum and define) --- lib/tokenize.cpp | 1 + test/testsimplifytokens.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index a4c8cf8f9..c2175c8c1 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7099,6 +7099,7 @@ void Tokenizer::simplifyEnum() if (ev.start == NULL) { tok1 = ev.value; lastEnumValueStart = lastEnumValueEnd = NULL; + lastValue = MathLib::toLongNumber(ev.value->str()); } } } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 7da778720..466a1c7eb 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -347,6 +347,7 @@ private: TEST_CASE(enum28); TEST_CASE(enum29); // ticket #3747 (bitwise or value) TEST_CASE(enum30); // ticket #3852 (false positive) + TEST_CASE(enum31); // ticket #3934 (calculation in first item) // remove "std::" on some standard functions TEST_CASE(removestd); @@ -7027,6 +7028,10 @@ private: TODO_ASSERT_EQUALS("","[test.cpp:12] -> [test.cpp:7]: (style) Variable 'two' hides enumerator with same name\n", errout.str()); } + void enum31() { // #3934 - calculation in first item + const char code[] = "enum { x=2*32, y }; i = y;"; + ASSERT_EQUALS("i = 65 ;", checkSimplifyEnum(code)); + } void removestd() { ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));