Fix #10837 crash/hang in expandTemplate (#5410)

This commit is contained in:
chrchr-github 2023-09-08 14:59:42 +02:00 committed by GitHub
parent 48a7a43ef2
commit e4f92f6979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -499,7 +499,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
return 0;
// num/type ..
if (!tok->isNumber() && tok->tokType() != Token::eChar && !tok->isName() && !tok->isOp())
if (!tok->isNumber() && tok->tokType() != Token::eChar && tok->tokType() != Token::eString && !tok->isName() && !tok->isOp())
return 0;
tok = tok->next();
if (!tok)

View File

@ -5319,6 +5319,7 @@ private:
ASSERT_EQUALS(3U, templateParameters("template <class T, class... Args, class Tup = std::tuple<Args*...>> void f() {}"));
ASSERT_EQUALS(1U, templateParameters("S<4 < sizeof(uintptr_t)> x;"));
ASSERT_EQUALS(2U, templateParameters("template <typename... Ts, typename = std::enable_if_t<std::is_same<Ts..., int>::value>> void g() {}")); // #11915
ASSERT_EQUALS(1U, templateParameters("S<N::M<O<\"A\"_I>>> s;")); // #10837
}
// Helper function to unit test TemplateSimplifier::getTemplateNamePosition