Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ const Token * Token::findClosingBracket() const
depth -= 2;
}
// save named template parameter
else if (templateParameter && depth == 1 && closing->str() == "," &&
else if (templateParameter && depth == 1 && Token::Match(closing, "[,=]") &&
closing->previous()->isName() && !Match(closing->previous(), "class|typename|."))
templateParameters.insert(closing->strAt(-1));
}
Expand Down
9 changes: 9 additions & 0 deletions test/testtoken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class TestToken : public TestFixture {
TEST_CASE(canFindMatchingBracketsWithTooManyOpening);
TEST_CASE(findClosingBracket);
TEST_CASE(findClosingBracket2);
TEST_CASE(findClosingBracket3);

TEST_CASE(expressionString);

Expand Down Expand Up @@ -1157,6 +1158,14 @@ class TestToken : public TestFixture {
ASSERT(t && Token::simpleMatch(t->findClosingBracket(), ">"));
}

void findClosingBracket3() {
const SimpleTokenizer var(*this, // #12789
"template <size_t I = 0, typename... ArgsT, std::enable_if_t<I < sizeof...(ArgsT)>* = nullptr>\n"
"void f();\n");
const Token* const t = Token::findsimplematch(var.tokens(), "<");
ASSERT(t && Token::simpleMatch(t->findClosingBracket(), ">"));
}

void expressionString() {
const SimpleTokenizer var1(*this, "void f() { *((unsigned long long *)x) = 0; }");
const Token *const tok1 = Token::findsimplematch(var1.tokens(), "*");
Expand Down