Fix #11795 debug: simplifyUsing: unmatched body end (#5198)

This commit is contained in:
chrchr-github 2023-06-27 15:45:25 +02:00 committed by GitHub
parent 9259aea317
commit 0a72cd3b72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -3251,7 +3251,7 @@ bool Tokenizer::simplifyUsing()
skip = true;
simplifyUsingError(usingStart, usingEnd);
}
tok1 = after;
tok1 = after->previous();
}
if (!skip)

View File

@ -72,6 +72,7 @@ private:
TEST_CASE(simplifyUsing25);
TEST_CASE(simplifyUsing26); // #11090
TEST_CASE(simplifyUsing27);
TEST_CASE(simplifyUsing28);
TEST_CASE(simplifyUsing8970);
TEST_CASE(simplifyUsing8971);
@ -675,6 +676,16 @@ private:
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"