Fix 9301: Syntax error when specializing template variable array (#3601)

This commit is contained in:
Paul Fultz II 2021-12-04 05:56:25 -06:00 committed by GitHub
parent 8dcea26c10
commit bc31419da0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -4530,7 +4530,8 @@ void Tokenizer::createLinks2()
} }
// if > is followed by [ .. "new a<b>[" is expected // if > is followed by [ .. "new a<b>[" is expected
// unless this is from varidiac expansion // unless this is from varidiac expansion
if (token->strAt(1) == "[" && !Token::simpleMatch(token->tokAt(-1), "... >")) { if (token->strAt(1) == "[" && !Token::simpleMatch(token->tokAt(-1), "... >") &&
!Token::Match(token->tokAt(1), "[ ]")) {
Token *prev = type.top()->previous(); Token *prev = type.top()->previous();
while (prev && Token::Match(prev->previous(), ":: %name%")) while (prev && Token::Match(prev->previous(), ":: %name%"))
prev = prev->tokAt(-2); prev = prev->tokAt(-2);

View File

@ -6711,6 +6711,10 @@ private:
"constexpr void constexpr_for_fold_impl([[maybe_unused]] Functor&& f, std::index_sequence<Indices...>) noexcept {\n" "constexpr void constexpr_for_fold_impl([[maybe_unused]] Functor&& f, std::index_sequence<Indices...>) noexcept {\n"
" (std::forward<Functor>(f).template operator() < First + Indices > (), ...);\n" " (std::forward<Functor>(f).template operator() < First + Indices > (), ...);\n"
"}\n")); "}\n"));
// #9301
ASSERT_NO_THROW(tokenizeAndStringify("template <typename> constexpr char x[] = \"\";\n"
"template <> constexpr char x<int>[] = \"\";\n"));
} }
void checkNamespaces() { void checkNamespaces() {