Skip to content

Commit

Permalink
Fix #12521 internalAstError with using declaration (#6134)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Mar 18, 2024
1 parent 49a34cd commit c3ceaa1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2849,8 +2849,8 @@ bool Tokenizer::simplifyUsing()
continue;
Token* end = tok->tokAt(3);
while (end && !Token::Match(end, "[;,]")) {
if (end->str() == "<" && end->link()) // skip template args
end = end->link()->next();
if (end->str() == "<") // skip template args
end = end->findClosingBracket();
else
end = end->next();
}
Expand Down
10 changes: 10 additions & 0 deletions test/testsimplifyusing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,16 @@ class TestSimplifyUsing : public TestFixture {
ASSERT_EQUALS(expected, tok(code, Platform::Type::Native, /*debugwarnings*/ true));
ASSERT_EQUALS("", errout_str());
}
{
const char code[] = "class T : private std::vector<std::pair<std::string, const int*>> {\n" // #12521
" using std::vector<std::pair<std::string, const int*>>::empty;\n"
"};\n";
const char expected[] = "class T : private std :: vector < std :: pair < std :: string , const int * > > { "
"using empty = std :: vector < std :: pair < std :: string , const int * > > :: empty ; "
"} ;";
ASSERT_EQUALS(expected, tok(code, Platform::Type::Native, /*debugwarnings*/ true));
ASSERT_EQUALS("", errout_str());
}
}

void simplifyUsing8970() {
Expand Down

0 comments on commit c3ceaa1

Please sign in to comment.