diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index f7fa47e01..7fd5b6d39 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -521,7 +521,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) return 0; // inner template - if (tok->str() == "<") { + if (tok->str() == "<" && tok->previous()->isName()) { ++level; tok = tok->next(); } diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 7caafd6c6..8783fec90 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -5300,6 +5300,7 @@ private: ASSERT_EQUALS(3U, templateParameters("template > constexpr void f() {}")); // #11351 ASSERT_EQUALS(3U, templateParameters("template > void f() {}")); ASSERT_EQUALS(3U, templateParameters("template > void f() {}")); + ASSERT_EQUALS(1U, templateParameters("S<4 < sizeof(uintptr_t)> x;")); } // Helper function to unit test TemplateSimplifier::getTemplateNamePosition