Skip to content

Commit

Permalink
Fix #11899 FP unusedScopedObject for function call and imported const…
Browse files Browse the repository at this point in the history
…ructor (#6620)
  • Loading branch information
chrchr-github authored Jul 21, 2024
1 parent 7964357 commit 450ea7c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ void Tokenizer::simplifyUsingToTypedef()
while (Token::Match(endtok, ":: %name%"))
endtok = endtok->tokAt(2);
if (endtok && endtok->str() == ";") {
if (endtok->strAt(-1) == endtok->strAt(-3))
continue;
tok->next()->str("typedef");
endtok = endtok->previous();
endtok->insertToken(endtok->str());
Expand Down
28 changes: 28 additions & 0 deletions test/testsimplifyusing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class TestSimplifyUsing : public TestFixture {
TEST_CASE(simplifyUsing28);
TEST_CASE(simplifyUsing29);
TEST_CASE(simplifyUsing30);
TEST_CASE(simplifyUsing31);

TEST_CASE(simplifyUsing8970);
TEST_CASE(simplifyUsing8971);
Expand Down Expand Up @@ -754,6 +755,33 @@ class TestSimplifyUsing : public TestFixture {
}
}

void simplifyUsing31() { // #11899
const char code[] = "struct B {\n"
" B();\n"
" void f();\n"
"};\n"
"struct D : B {\n"
" using B::B;\n"
" void g() {\n"
" B::f();\n"
" }\n"
" B b;\n"
"};\n";
const char expected[] = "struct B { "
"B ( ) ; "
"void f ( ) ; "
"} ; "
"struct D : B { "
"using B = B :: B ; "
"void g ( ) { "
"B :: f ( ) ; "
"} "
"B b ; "
"} ;";
ASSERT_EQUALS(expected, tok(code, Platform::Type::Native, /*debugwarnings*/ true));
ASSERT_EQUALS("", errout_str());
}

void simplifyUsing8970() {
const char code[] = "using V = std::vector<int>;\n"
"struct A {\n"
Expand Down

0 comments on commit 450ea7c

Please sign in to comment.