Fixed #4074 (Internal error. Token::Match called with varid 0)

This commit is contained in:
Daniel Marjamäki 2012-09-24 06:44:51 +02:00
parent 990340ba98
commit 0ff8105c71
2 changed files with 8 additions and 1 deletions

View File

@ -200,7 +200,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
return 0; return 0;
// num/type .. // num/type ..
if (!tok->isNumber() && !tok->isName()) if (!tok->isNumber() && tok->type() != Token::eChar && !tok->isName())
return 0; return 0;
tok = tok->next(); tok = tok->next();
if (!tok) if (!tok)

View File

@ -126,6 +126,7 @@ private:
TEST_CASE(template32); // #3818 - mismatching template not handled well TEST_CASE(template32); // #3818 - mismatching template not handled well
TEST_CASE(template33); // #3818 - inner templates in template instantiation not handled well TEST_CASE(template33); // #3818 - inner templates in template instantiation not handled well
TEST_CASE(template34); // #3706 - namespace => hang TEST_CASE(template34); // #3706 - namespace => hang
TEST_CASE(template35); // #4074 - A<'x'> a;
TEST_CASE(template_unhandled); TEST_CASE(template_unhandled);
TEST_CASE(template_default_parameter); TEST_CASE(template_default_parameter);
TEST_CASE(template_default_type); TEST_CASE(template_default_type);
@ -2217,6 +2218,12 @@ private:
"template < > int X < int > :: Y ( 0 ) ;", tok(code)); "template < > int X < int > :: Y ( 0 ) ;", tok(code));
} }
void template35() { // #4074 - "A<'x'> a;" is not recognized as template instantiation
const char code[] = "template <char c> class A {};\n"
"A<'x'> a;";
ASSERT_EQUALS("A<'x'> a ; class A<'x'> { }", tok(code));
}
void template_unhandled() { void template_unhandled() {
// An unhandled template usage should be simplified.. // An unhandled template usage should be simplified..
ASSERT_EQUALS("x<int> ( ) ;", tok("x<int>();")); ASSERT_EQUALS("x<int> ( ) ;", tok("x<int>();"));