Skip to content

Commit 4412833

Browse files
Fix #14612 Internal error: "Cannot find end of expression" (#8354)
1 parent 8119a9d commit 4412833

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5544,7 +5544,7 @@ void Tokenizer::createLinks2()
55445544

55455545
while (!type.empty() && type.top()->str() == "<") {
55465546
const Token* end = type.top()->findClosingBracket();
5547-
if (Token::Match(end, "> %comp%|;|.|=|{|(|::"))
5547+
if (Token::Match(end, "> %comp%|;|.|=|{|(|)|::"))
55485548
break;
55495549
// Variable declaration
55505550
if (Token::Match(end, "> %var% ;") && (type.top()->tokAt(-2) == nullptr || Token::Match(type.top()->tokAt(-2), ";|}|{")))

test/testtokenize.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3829,6 +3829,19 @@ class TestTokenizer : public TestFixture {
38293829
ASSERT_EQUALS(true, tok1->link() == tok2);
38303830
ASSERT_EQUALS(true, tok2->link() == tok1);
38313831
}
3832+
3833+
{
3834+
const char code[] = "template <typename Fn, typename... Args>\n" // #14612
3835+
"void f(Fn && fn, Args&&... args) {\n"
3836+
" static_assert(std::is_invocable_v<Fn&&, Args&&...>);\n"
3837+
"}\n";
3838+
SimpleTokenizer tokenizer(settings0, *this);
3839+
ASSERT(tokenizer.tokenize(code));
3840+
const Token* tok1 = Token::findsimplematch(tokenizer.tokens(), "< Fn");
3841+
const Token* tok2 = Token::findsimplematch(tok1, "> )");
3842+
ASSERT_EQUALS(true, tok1->link() == tok2);
3843+
ASSERT_EQUALS(true, tok2->link() == tok1);
3844+
}
38323845
}
38333846

38343847
void simplifyString() {

0 commit comments

Comments
 (0)