Fix #11351 Assert failure in templatesimplifier.cpp (#4552)

This commit is contained in:
chrchr-github 2022-10-16 19:34:25 +02:00 committed by GitHub
parent 221873e69f
commit c6c339a3e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -438,7 +438,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
// Skip variadic types (Ticket #5774, #6059, #6172)
if (Token::simpleMatch(tok, "...")) {
if ((tok->previous()->isName() && !Token::Match(tok->tokAt(-2), "<|,|::")) ||
(!tok->previous()->isName() && tok->strAt(-1) != ">"))
(!tok->previous()->isName() && !Token::Match(tok->previous(), ">|&")))
return 0; // syntax error
tok = tok->next();
if (!tok)

View File

@ -5297,6 +5297,7 @@ private:
ASSERT_EQUALS(4U, templateParameters("template<template<typename>...Foo,int,template<template<template<typename>>>,int> x;"));
ASSERT_EQUALS(2U, templateParameters("template<typename S, enable_if_t<(is_compile_string<S>::value), int>> void i(S s);"));
ASSERT_EQUALS(2U, templateParameters("template<typename c, b<(c::d), int>> void e();"));
ASSERT_EQUALS(3U, templateParameters("template <class T, class... Args, class Tup = std::tuple<Args&...>> constexpr void f() {}")); // #11351
}
// Helper function to unit test TemplateSimplifier::getTemplateNamePosition