Skip to content

Commit

Permalink
Fix 10651: Crash on static template method (danmar#3633)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 authored Dec 16, 2021
1 parent e8260f2 commit ac4f425
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/templatesimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ void TemplateSimplifier::expandTemplate(
mTokenList.addtoken(tokSemicolon, tokSemicolon->linenr(), tokSemicolon->column(), tokSemicolon->fileIndex());
}
brackets.pop();
if (brackets.empty() && !Token::Match(tok3, "} >|,|{|%cop%")) {
if (brackets.empty() && !Token::Match(tok3, "} >|,|{")) {
inTemplateDefinition = false;
break;
}
Expand Down
7 changes: 7 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6765,6 +6765,13 @@ class TestTokenizer : public TestFixture {
// #9301
ASSERT_NO_THROW(tokenizeAndStringify("template <typename> constexpr char x[] = \"\";\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() {
Expand Down

0 comments on commit ac4f425

Please sign in to comment.