diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 79946d729..82d9c8881 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3093,7 +3093,8 @@ void Tokenizer::simplifyTemplatesInstantiate(const Token *tok, for (const Token *tok3 = tok2->tokAt(2); tok3 && tok3->str() != ">"; tok3 = tok3->next()) { // #2648 - unhandled parenthesis => bail out - if (tok3->str() == "(") + // #2721 - unhandled [ => bail out + if (tok3->str() == "(" || tok3->str() == "[") { s.clear(); break; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index e4a7ad008..20f25ac29 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -116,6 +116,7 @@ private: TEST_CASE(template23); TEST_CASE(template24); // #2648 - using sizeof in template parameter TEST_CASE(template25); // #2648 - another test for sizeof template parameter + TEST_CASE(template26); // #2721 - passing 'char[2]' as template parameter TEST_CASE(template_unhandled); TEST_CASE(template_default_parameter); TEST_CASE(template_default_type); @@ -2094,6 +2095,20 @@ private: } + void template26() + { + // #2721 + const char code[] = "template\n" + "class A { public: T x; };\n" + "\n" + "template\n" + "class C: public A {};\n" + "\n" + "C<2> a;\n"; + // TODO: expand A also + ASSERT_EQUALS("; C<2> a ; class C<2> : public A < char [ 2 ] > { }", sizeof_(code)); + } + void template_unhandled() { // An unhandled template usage should be simplified..