Fix 10651: Crash on static template method (#3633)

This commit is contained in:
Paul Fultz II 2021-12-16 15:32:44 -06:00 committed by GitHub
parent e8260f2dcc
commit ac4f4258a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -2221,7 +2221,7 @@ void TemplateSimplifier::expandTemplate(
mTokenList.addtoken(tokSemicolon, tokSemicolon->linenr(), tokSemicolon->column(), tokSemicolon->fileIndex()); mTokenList.addtoken(tokSemicolon, tokSemicolon->linenr(), tokSemicolon->column(), tokSemicolon->fileIndex());
} }
brackets.pop(); brackets.pop();
if (brackets.empty() && !Token::Match(tok3, "} >|,|{|%cop%")) { if (brackets.empty() && !Token::Match(tok3, "} >|,|{")) {
inTemplateDefinition = false; inTemplateDefinition = false;
break; break;
} }

View File

@ -6765,6 +6765,13 @@ private:
// #9301 // #9301
ASSERT_NO_THROW(tokenizeAndStringify("template <typename> constexpr char x[] = \"\";\n" ASSERT_NO_THROW(tokenizeAndStringify("template <typename> constexpr char x[] = \"\";\n"
"template <> constexpr char x<int>[] = \"\";\n")); "template <> constexpr char x<int>[] = \"\";\n"));
// #10951
ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n"
" template <class> static void b() {}\n"
" ~a();\n"
"};\n"
"void d() { a::b<int>(); }\n"));
} }
void checkNamespaces() { void checkNamespaces() {