Fix #11506 debug: simplifyUsing: unmatched body end (#4728)

This commit is contained in:
chrchr-github 2023-01-27 08:19:32 +01:00 committed by GitHub
parent 1d3955bd92
commit 7eb1da9ffc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -1360,7 +1360,7 @@ void Tokenizer::simplifyTypedef()
const bool sameStartEnd = (typeStart == typeEnd);
// check for derived class: class A : some_typedef {
const bool isDerived = Token::Match(tok2->previous(), "public|protected|private %type% {|,");
const bool isDerived = Token::Match(tok2->previous(), "public|protected|private|: %type% {|,");
// check for cast: (some_typedef) A or static_cast<some_typedef>(A)
// todo: check for more complicated casts like: (const some_typedef *)A

View File

@ -189,6 +189,7 @@ private:
TEST_CASE(simplifyTypedef140); // #10798
TEST_CASE(simplifyTypedef141); // #10144
TEST_CASE(simplifyTypedef142); // T() when T is a pointer type
TEST_CASE(simplifyTypedef143); // #11506
TEST_CASE(simplifyTypedef144); // #9353
TEST_CASE(simplifyTypedefFunction1);
@ -3071,6 +3072,16 @@ private:
ASSERT_EQUALS("void f ( int * = ( int * ) 0 ) { }", tok(code2));
}
void simplifyTypedef143() { // #11506
const char code[] = "typedef struct { int i; } B;\n"
"void f() {\n"
" struct D : B {\n"
" char c;\n"
" };\n"
"}\n";
ASSERT_EQUALS("struct B { int i ; } ; void f ( ) { struct D : B { char c ; } ; }", tok(code));
}
void simplifyTypedef144() { // #9353
const char code[] = "typedef struct {} X;\n"
"std::vector<X> v;\n";