fix missing pop in Tokenizer::simplifyStructDecl() when anonymous struct/union removed
This commit is contained in:
parent
b32b2c6d87
commit
8ec1dfacbf
|
@ -9434,6 +9434,7 @@ void Tokenizer::simplifyStructDecl()
|
||||||
// don't remove unnamed anonymous unions from a class, struct or union
|
// don't remove unnamed anonymous unions from a class, struct or union
|
||||||
if (!(tok1->str() == "union" && !inFunction))
|
if (!(tok1->str() == "union" && !inFunction))
|
||||||
{
|
{
|
||||||
|
skip.pop_back();
|
||||||
tok1->deleteThis();
|
tok1->deleteThis();
|
||||||
if (tok1->next() == tok)
|
if (tok1->next() == tok)
|
||||||
{
|
{
|
||||||
|
|
|
@ -336,6 +336,7 @@ private:
|
||||||
TEST_CASE(simplifyStructDecl1);
|
TEST_CASE(simplifyStructDecl1);
|
||||||
TEST_CASE(simplifyStructDecl2); // ticket #2579
|
TEST_CASE(simplifyStructDecl2); // ticket #2579
|
||||||
TEST_CASE(simplifyStructDecl3);
|
TEST_CASE(simplifyStructDecl3);
|
||||||
|
TEST_CASE(simplifyStructDecl4);
|
||||||
|
|
||||||
// register int var; => int var;
|
// register int var; => int var;
|
||||||
// inline int foo() {} => int foo() {}
|
// inline int foo() {} => int foo() {}
|
||||||
|
@ -7055,6 +7056,37 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyStructDecl4()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
const char code[] = "class ABC {\n"
|
||||||
|
" void foo() {\n"
|
||||||
|
" union {\n"
|
||||||
|
" int i;\n"
|
||||||
|
" float f;\n"
|
||||||
|
" };\n"
|
||||||
|
" struct Fee { } fee;\n"
|
||||||
|
" }\n"
|
||||||
|
" union {\n"
|
||||||
|
" long long ll;\n"
|
||||||
|
" double d;\n"
|
||||||
|
" };\n"
|
||||||
|
"} abc;\n";
|
||||||
|
const char expected[] = "class ABC { "
|
||||||
|
"void foo ( ) { "
|
||||||
|
"int i ; "
|
||||||
|
"float & f = i ; "
|
||||||
|
"struct Fee { } ; Fee fee ; "
|
||||||
|
"} "
|
||||||
|
"union { "
|
||||||
|
"long long ll ; "
|
||||||
|
"double d ; "
|
||||||
|
"} ; "
|
||||||
|
"} ; ABC abc ;";
|
||||||
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void removeUnwantedKeywords()
|
void removeUnwantedKeywords()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("int var ;", tok("register int var ;", true));
|
ASSERT_EQUALS("int var ;", tok("register int var ;", true));
|
||||||
|
|
Loading…
Reference in New Issue