Don't throw internalAstError for parameter pack in template argument list (#4773)

This commit is contained in:
chrchr-github 2023-02-15 19:43:18 +01:00 committed by GitHub
parent 4f8329b2df
commit 33a03f2c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -691,7 +691,7 @@ static bool iscpp11init_impl(const Token * const tok)
if (!Token::simpleMatch(endtok, "} ;")) if (!Token::simpleMatch(endtok, "} ;"))
return true; return true;
const Token *prev = nameToken; const Token *prev = nameToken;
while (Token::Match(prev, "%name%|::|:|<|>|(|)|,|%num%|%cop%")) { while (Token::Match(prev, "%name%|::|:|<|>|(|)|,|%num%|%cop%|...")) {
if (Token::Match(prev, "class|struct|union|enum")) if (Token::Match(prev, "class|struct|union|enum"))
return false; return false;

View File

@ -7662,6 +7662,16 @@ private:
"{ } }", "{ } }",
TokenImpl::Cpp11init::NOINIT); TokenImpl::Cpp11init::NOINIT);
testIsCpp11init("struct S {};\n"
"template<class... Args>\n"
"struct T;\n"
"template<class... Args>\n"
"struct T<void, Args...> final : S {\n"
" void operator()(Args...) {}\n"
"};\n",
"{ void",
TokenImpl::Cpp11init::NOINIT);
ASSERT_NO_THROW(tokenizeAndStringify("template<typename U> struct X {};\n" // don't crash ASSERT_NO_THROW(tokenizeAndStringify("template<typename U> struct X {};\n" // don't crash
"template<typename T> auto f(T t) -> X<decltype(t + 1)> {}\n")); "template<typename T> auto f(T t) -> X<decltype(t + 1)> {}\n"));
#undef testIsCpp11init #undef testIsCpp11init