Skip to content

Commit

Permalink
Handle additional example
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 4, 2024
1 parent 3f6df48 commit 592b55c
Show file tree
Hide file tree
Showing 2 changed files with 14 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 @@ -822,8 +822,8 @@ namespace {
}

// don't add class|struct|union in inheritance list
if (Token::Match(tok->previous(), "public|private|protected") && Token::Match(mRangeType.first, "class|struct|union"))
mRangeType.first = mRangeType.first->next();
if (Token::Match(tok->previous(), "public|private|protected") && Token::Match(mRangeType.first, "const| class|struct|union"))
mRangeType.first = mRangeType.first->tokAt(mRangeType.first->str() == "const" ? 2 : 1);

Token* const tok2 = insertTokens(tok, mRangeType);
Token* const tok3 = insertTokens(tok2, mRangeTypeQualifiers);
Expand Down
12 changes: 12 additions & 0 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,18 @@ class TestSimplifyTypedef : public TestFixture {
ASSERT_EQUALS(expected, tok(code));
ASSERT_EQUALS("", errout.str());
}

{
const char code[] = "struct B {};\n" // #12141
"typedef const struct B CB;\n"
"namespace N {\n"
" struct D : public CB {};\n"
"}\n";

const char expected[] = "struct B { } ; namespace N { struct D : public B { } ; }";
ASSERT_EQUALS(expected, tok(code));
ASSERT_EQUALS("", errout.str());
}
}

void simplifyTypedef45() {
Expand Down

0 comments on commit 592b55c

Please sign in to comment.