Skip to content

Commit e69733b

Browse files
committed
Partial fix for #14982 internalAstError for function with std::enable_if
1 parent 2e19539 commit e69733b

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lib/tokenize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5647,6 +5647,8 @@ void Tokenizer::createLinks2()
56475647
const Token* end = type.top()->findClosingBracket();
56485648
if (Token::Match(end, "> %comp%|;|.|=|{|}|(|)|::"))
56495649
break;
5650+
if (Token::Match(end, "> %name% ("))
5651+
break;
56505652
// Variable declaration
56515653
if (Token::Match(end, "> %var% ;") && (type.top()->tokAt(-2) == nullptr || Token::Match(type.top()->tokAt(-2), ";|}|{")))
56525654
break;

test/testtokenize.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3933,6 +3933,16 @@ class TestTokenizer : public TestFixture {
39333933
ASSERT_EQUALS(true, tok1->link() == tok2);
39343934
ASSERT_EQUALS(true, tok2->link() == tok1);
39353935
}
3936+
3937+
{
3938+
const char code[] = "std::enable_if_t<0 || 1, void> f() {}\n"; // #14982
3939+
SimpleTokenizer tokenizer(settingsDefault, *this);
3940+
ASSERT(tokenizer.tokenize(code));
3941+
const Token* tok1 = Token::findsimplematch(tokenizer.tokens(), "< 0");
3942+
const Token* tok2 = Token::findsimplematch(tok1, "> f");
3943+
ASSERT_EQUALS(true, tok1->link() == tok2);
3944+
ASSERT_EQUALS(true, tok2->link() == tok1);
3945+
}
39363946
}
39373947

39383948
void simplifyString() {

0 commit comments

Comments
 (0)