Skip to content

Commit 0e57c27

Browse files
Fix #11386 debug: CheckClass::checkConst found unlinked template argument list (cppcheck-opensource#4614)
1 parent d5d7446 commit 0e57c27

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

lib/templatesimplifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
521521
return 0;
522522

523523
// inner template
524-
if (tok->str() == "<") {
524+
if (tok->str() == "<" && tok->previous()->isName()) {
525525
++level;
526526
tok = tok->next();
527527
}

test/testsimplifytemplate.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5300,6 +5300,7 @@ class TestSimplifyTemplate : public TestFixture {
53005300
ASSERT_EQUALS(3U, templateParameters("template <class T, class... Args, class Tup = std::tuple<Args&...>> constexpr void f() {}")); // #11351
53015301
ASSERT_EQUALS(3U, templateParameters("template <class T, class... Args, class Tup = std::tuple<Args&&...>> void f() {}"));
53025302
ASSERT_EQUALS(3U, templateParameters("template <class T, class... Args, class Tup = std::tuple<Args*...>> void f() {}"));
5303+
ASSERT_EQUALS(1U, templateParameters("S<4 < sizeof(uintptr_t)> x;"));
53035304
}
53045305

53055306
// Helper function to unit test TemplateSimplifier::getTemplateNamePosition

0 commit comments

Comments
 (0)