diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f9547e7ba..7d917eb6c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7572,7 +7572,9 @@ void Tokenizer::simplifyEnum() endtoken = endtoken->next(); if (Token::Match(endtoken, "*|,|::|typename")) endtoken = endtoken->next(); - } while (Token::Match(endtoken, "%var%|%num% *| [,>]") || Token::Match(endtoken, "%var%|%num% :: %any%")); + if (endtoken->str() == "<" && TemplateSimplifier::templateParameters(endtoken)) + endtoken = endtoken->findClosingBracket(); + } while (Token::Match(endtoken, "%var%|%num% *| [,>]") || Token::Match(endtoken, "%var%|%num% ::|< %any%")); if (endtoken->str() == ">") { enumValueEnd = endtoken; if (Token::simpleMatch(endtoken, "> ( )")) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index a39f4fe06..823782d27 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -2414,6 +2414,12 @@ private: "enum { e = sizeof(A) }; " "template struct B {};"); ASSERT_EQUALS("", errout.str()); + tok("template struct A { static const int value = 0; }; " + "template struct B { typedef int type; }; " + "template struct C { " + " enum { value = A::type, int>::value }; " + "};"); + ASSERT_EQUALS("", errout.str()); } void template_default_parameter() {