From 33a03f2c354d0557aebf6d98ded26ae3332ad7f3 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 15 Feb 2023 19:43:18 +0100 Subject: [PATCH] Don't throw internalAstError for parameter pack in template argument list (#4773) --- lib/tokenlist.cpp | 2 +- test/testtokenize.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index a521f9486..380446b32 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -691,7 +691,7 @@ static bool iscpp11init_impl(const Token * const tok) if (!Token::simpleMatch(endtok, "} ;")) return true; 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")) return false; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index d6e814d7d..c7ba4c68f 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7662,6 +7662,16 @@ private: "{ } }", TokenImpl::Cpp11init::NOINIT); + testIsCpp11init("struct S {};\n" + "template\n" + "struct T;\n" + "template\n" + "struct T final : S {\n" + " void operator()(Args...) {}\n" + "};\n", + "{ void", + TokenImpl::Cpp11init::NOINIT); + ASSERT_NO_THROW(tokenizeAndStringify("template struct X {};\n" // don't crash "template auto f(T t) -> X {}\n")); #undef testIsCpp11init