File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7648,10 +7648,10 @@ void Tokenizer::simplifyEnum()
76487648 ev = &(enumValues.find (tok2->str ())->second );
76497649 if (!duplicateDefinition (&tok2, ev->name )) {
76507650 if (tok2->strAt (-1 ) == " ::" ||
7651- Token::Match (tok2->next (), " ::|[" )) {
7651+ Token::Match (tok2->next (), " ::|[|= " )) {
76527652 // Don't replace this enum if:
76537653 // * it's preceded or followed by "::"
7654- // * it's followed by "["
7654+ // * it's followed by "[" or "="
76557655 } else {
76567656 simplify = true ;
76577657 ev = &(enumValues.find (tok2->str ())->second );
Original file line number Diff line number Diff line change @@ -373,6 +373,7 @@ class TestSimplifyTokens : public TestFixture {
373373 TEST_CASE (enum40);
374374 TEST_CASE (enum41); // ticket #5212 (valgrind errors during enum simplification)
375375 TEST_CASE (enum42); // ticket #5182 (template function call in enum value)
376+ TEST_CASE (enum43); // lhs in assignment
376377 TEST_CASE (enumscope1); // ticket #3949
377378 TEST_CASE (duplicateDefinition); // ticket #3565
378379 TEST_CASE (invalid_enum); // #5600
@@ -7161,6 +7162,12 @@ class TestSimplifyTokens : public TestFixture {
71617162 ASSERT_EQUALS (" a = f < int , 2 > ( ) ;" , checkSimplifyEnum (code));
71627163 }
71637164
7165+ void enum43 () { // lhs in assignment
7166+ const char code[] = " enum { A, B };\n "
7167+ " A = 1;" ;
7168+ ASSERT_EQUALS (" A = 1 ;" , checkSimplifyEnum (code));
7169+ }
7170+
71647171 void enumscope1 () { // #3949 - don't simplify enum from one function in another function
71657172 const char code[] = " void foo() { enum { A = 0, B = 1 }; }\n "
71667173 " void bar() { int a = A; }" ;
You can’t perform that action at this time.
0 commit comments