Merge pull request #314 from simartin/ticket_5816_2

Ticket #5816: Properly handle template'd template parameters in enum initializers
This commit is contained in:
PKEuS 2014-05-23 23:08:33 +02:00
commit e1ad71dba5
2 changed files with 9 additions and 1 deletions

View File

@ -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, "> ( )"))

View File

@ -2414,6 +2414,12 @@ private:
"enum { e = sizeof(A<int, int>) }; "
"template <class T, class U> struct B {};");
ASSERT_EQUALS("", errout.str());
tok("template<class T, class U> struct A { static const int value = 0; }; "
"template<class T> struct B { typedef int type; }; "
"template <class T> struct C { "
" enum { value = A<typename B<T>::type, int>::value }; "
"};");
ASSERT_EQUALS("", errout.str());
}
void template_default_parameter() {