From 0ff8105c7153505dd6d4540ac78876a0f117dbac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 24 Sep 2012 06:44:51 +0200 Subject: [PATCH] Fixed #4074 (Internal error. Token::Match called with varid 0) --- lib/templatesimplifier.cpp | 2 +- test/testsimplifytokens.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 54a06d7d8..1ab94fb75 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -200,7 +200,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) return 0; // num/type .. - if (!tok->isNumber() && !tok->isName()) + if (!tok->isNumber() && tok->type() != Token::eChar && !tok->isName()) return 0; tok = tok->next(); if (!tok) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 30912551c..a5f61654f 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -126,6 +126,7 @@ private: TEST_CASE(template32); // #3818 - mismatching template not handled well TEST_CASE(template33); // #3818 - inner templates in template instantiation not handled well TEST_CASE(template34); // #3706 - namespace => hang + TEST_CASE(template35); // #4074 - A<'x'> a; TEST_CASE(template_unhandled); TEST_CASE(template_default_parameter); TEST_CASE(template_default_type); @@ -2217,6 +2218,12 @@ private: "template < > int X < int > :: Y ( 0 ) ;", tok(code)); } + void template35() { // #4074 - "A<'x'> a;" is not recognized as template instantiation + const char code[] = "template class A {};\n" + "A<'x'> a;"; + ASSERT_EQUALS("A<'x'> a ; class A<'x'> { }", tok(code)); + } + void template_unhandled() { // An unhandled template usage should be simplified.. ASSERT_EQUALS("x ( ) ;", tok("x();"));