diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 6fdd423628b..24cc0bcbe1d 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -496,7 +496,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) return 0; // num/type .. - if (!tok->isNumber() && tok->tokType() != Token::eChar && tok->tokType() != Token::eString && !tok->isName() && !tok->isOp()) + if (!tok->isNumber() && tok->tokType() != Token::eChar && tok->tokType() != Token::eString && !tok->isName() && !tok->isOp() && tok->str() != ".") return 0; tok = tok->next(); if (!tok) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index c4de2be00e7..a6741a99243 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -240,6 +240,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(vardecl_stl_3); TEST_CASE(vardecl_template_1); TEST_CASE(vardecl_template_2); + TEST_CASE(vardecl_template_3); TEST_CASE(vardecl_union); TEST_CASE(vardecl_par); // #2743 - set links if variable type contains parentheses TEST_CASE(vardecl_par2); // #3912 - set correct links @@ -2387,6 +2388,19 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(expected, tokenizeAndStringify(code)); } + void vardecl_template_3() { + const char code[] = "template \n" // #14909 + "void f(T x) {\n" + " const auto y = h;\n" + "}"; + const char expected[] = "template < class T >\n" + "void f ( T x ) {\n" + "const auto y = h < T , x . size ( ) > ;\n" + "}"; + ASSERT_EQUALS(expected, tokenizeAndStringify(code)); + ASSERT_EQUALS("[test.cpp:3:11]: (debug) auto token with no type. [autoNoType]\n", errout_str()); + } + void vardecl_union() { // ticket #1976 const char code1[] = "class Fred { public: union { int a ; int b ; } ; } ;";