Fixed #4644: Don't assign varid to template parameter when 'typename' is used

This commit is contained in:
PKEuS 2013-03-10 06:11:25 -07:00
parent 1f40af2ae2
commit b3a9ac5c3b
2 changed files with 7 additions and 1 deletions

View File

@ -2712,7 +2712,7 @@ void Tokenizer::setVarId()
notstart.insert("return"); notstart.insert("return");
notstart.insert("sizeof"); notstart.insert("sizeof");
if (!isC()) { if (!isC()) {
static const char *str[] = {"delete","friend","new","throw","using","virtual","explicit"}; static const char *str[] = {"delete","friend","new","throw","using","virtual","explicit","typename"};
notstart.insert(str, str+(sizeof(str)/sizeof(*str))); notstart.insert(str, str+(sizeof(str)/sizeof(*str)));
} }

View File

@ -270,6 +270,7 @@ private:
TEST_CASE(varid_templatePtr); // #4319 TEST_CASE(varid_templatePtr); // #4319
TEST_CASE(varid_templateNamespaceFuncPtr); // #4172 TEST_CASE(varid_templateNamespaceFuncPtr); // #4172
TEST_CASE(varid_variadicFunc); TEST_CASE(varid_variadicFunc);
TEST_CASE(varid_typename); // #4644
TEST_CASE(varidclass1); TEST_CASE(varidclass1);
TEST_CASE(varidclass2); TEST_CASE(varidclass2);
@ -4283,6 +4284,11 @@ private:
"1: int foo ( . . . ) ;\n", tokenizeDebugListing("int foo(...);")); "1: int foo ( . . . ) ;\n", tokenizeDebugListing("int foo(...);"));
} }
void varid_typename() {
ASSERT_EQUALS("\n\n##file 0\n"
"1: template < int d , typename A , typename B >\n", tokenizeDebugListing("template<int d, typename A, typename B>"));
}
void varidclass1() { void varidclass1() {
const std::string actual = tokenizeDebugListing( const std::string actual = tokenizeDebugListing(
"class Fred\n" "class Fred\n"