Skip to content

Commit

Permalink
Fix #11795 debug: simplifyUsing: unmatched body end
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jun 26, 2023
1 parent 9dc38f8 commit b1395b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3251,7 +3251,7 @@ bool Tokenizer::simplifyUsing()
skip = true;
simplifyUsingError(usingStart, usingEnd);
}
tok1 = after;
tok1 = after->previous();
}

if (!skip)
Expand Down
11 changes: 11 additions & 0 deletions test/testsimplifyusing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class TestSimplifyUsing : public TestFixture {
TEST_CASE(simplifyUsing25);
TEST_CASE(simplifyUsing26); // #11090
TEST_CASE(simplifyUsing27);
TEST_CASE(simplifyUsing28);

TEST_CASE(simplifyUsing8970);
TEST_CASE(simplifyUsing8971);
Expand Down Expand Up @@ -675,6 +676,16 @@ class TestSimplifyUsing : public TestFixture {
ASSERT_EQUALS(expected, tok(code));
}

void simplifyUsing28() { // #11795
const char code[] = "void f() {\n"
" using T = int;\n"
" T* p{ new T };\n"
"}\n";
const char expected[] = "void f ( ) { int * p { new int } ; }";
ASSERT_EQUALS(expected, tok(code, cppcheck::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 b1395b7

Please sign in to comment.