Skip to content

Commit 0630d8a

Browse files
Partial fix for #14982 internalAstError for function with std::enable_if (#8810)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 6d2b6f4 commit 0630d8a

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

lib/tokenize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5650,6 +5650,8 @@ void Tokenizer::createLinks2()
56505650
const Token* end = type.top()->findClosingBracket();
56515651
if (Token::Match(end, "> %comp%|;|.|=|{|}|(|)|::"))
56525652
break;
5653+
if (Token::Match(end, "> %name% (|::"))
5654+
break;
56535655
// Variable declaration
56545656
if (Token::Match(end, "> %var% ;") && (type.top()->tokAt(-2) == nullptr || Token::Match(type.top()->tokAt(-2), ";|}|{")))
56555657
break;

test/testtokenize.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4004,6 +4004,21 @@ class TestTokenizer : public TestFixture {
40044004
ASSERT_EQUALS(true, tok1->link() == tok2);
40054005
ASSERT_EQUALS(true, tok2->link() == tok1);
40064006
}
4007+
4008+
{
4009+
const char code[] = "std::enable_if_t<0 || 1, void> f() {}\n" // #14982
4010+
"std::enable_if_t<0 || 1, void> S::g() {}\n";
4011+
SimpleTokenizer tokenizer(settingsDefault, *this);
4012+
ASSERT(tokenizer.tokenize(code));
4013+
const Token* tok1 = Token::findsimplematch(tokenizer.tokens(), "< 0");
4014+
const Token* tok2 = Token::findsimplematch(tok1, "> f");
4015+
ASSERT_EQUALS(true, tok1->link() == tok2);
4016+
ASSERT_EQUALS(true, tok2->link() == tok1);
4017+
const Token* tok3 = Token::findsimplematch(tok2, "< 0");
4018+
const Token* tok4 = Token::findsimplematch(tok3, "> S");
4019+
ASSERT_EQUALS(true, tok3->link() == tok4);
4020+
ASSERT_EQUALS(true, tok4->link() == tok3);
4021+
}
40074022
}
40084023

40094024
void simplifyString() {

0 commit comments

Comments
 (0)