From 0e57c27dd3c545a19b08936e2e712f4fc63b6720 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 7 Dec 2022 09:12:46 +0100 Subject: [PATCH] Fix #11386 debug: CheckClass::checkConst found unlinked template argument list (#4614) --- lib/templatesimplifier.cpp | 2 +- test/testsimplifytemplate.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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