From 03026c73045020dde250c531acbafe7cf87459f4 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 5 Sep 2023 00:35:33 +0200 Subject: [PATCH] Fix #11915 Assert failure in getTemplateNamePosition() (#5403) --- lib/templatesimplifier.cpp | 5 +++-- test/testsimplifytemplate.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index f906fbb91..72b4aee34 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -454,8 +454,9 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) if (level == 1) return numberOfParameters; level -= 2; - } else if (tok->str() == "," && level == 0) { - ++numberOfParameters; + } else if (tok->str() == ",") { + if (level == 0) + ++numberOfParameters; tok = tok->next(); continue; } diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index 73b851991..97ebef398 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -5318,6 +5318,7 @@ private: ASSERT_EQUALS(3U, templateParameters("template > void f() {}")); ASSERT_EQUALS(3U, templateParameters("template > void f() {}")); ASSERT_EQUALS(1U, templateParameters("S<4 < sizeof(uintptr_t)> x;")); + ASSERT_EQUALS(2U, templateParameters("template ::value>> void g() {}")); // #11915 } // Helper function to unit test TemplateSimplifier::getTemplateNamePosition