Skip to content

Commit

Permalink
Added test case from #3533 (segmentation fault of cppcheck).
Browse files Browse the repository at this point in the history
  • Loading branch information
Edoardo Prezioso committed Jan 31, 2012
1 parent 86a5a9a commit f8578a3
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions test/testsimplifytokens.cpp
Expand Up @@ -365,6 +365,7 @@ class TestSimplifyTokens : public TestFixture {
TEST_CASE(simplifyStructDecl2); // ticket #2579 TEST_CASE(simplifyStructDecl2); // ticket #2579
TEST_CASE(simplifyStructDecl3); TEST_CASE(simplifyStructDecl3);
TEST_CASE(simplifyStructDecl4); TEST_CASE(simplifyStructDecl4);
TEST_CASE(simplifyStructDecl5); // ticket #3533 (segmentation fault)


// register int var; => int var; // register int var; => int var;
// inline int foo() {} => int foo() {} // inline int foo() {} => int foo() {}
Expand Down Expand Up @@ -7375,33 +7376,42 @@ class TestSimplifyTokens : public TestFixture {
} }


void simplifyStructDecl4() { void simplifyStructDecl4() {
{ const char code[] = "class ABC {\n"
const char code[] = "class ABC {\n" " void foo() {\n"
" void foo() {\n" " union {\n"
" union {\n" " int i;\n"
" int i;\n" " float f;\n"
" float f;\n" " };\n"
" };\n" " struct Fee { } fee;\n"
" struct Fee { } fee;\n" " }\n"
" }\n" " union {\n"
" union {\n" " long long ll;\n"
" long long ll;\n" " double d;\n"
" double d;\n" " };\n"
" };\n" "} abc;\n";
"} abc;\n"; const char expected[] = "class ABC { "
const char expected[] = "class ABC { " "void foo ( ) { "
"void foo ( ) { " "int i ; "
"int i ; " "float & f = i ; "
"float & f = i ; " "struct Fee { } ; Fee fee ; "
"struct Fee { } ; Fee fee ; " "} "
"} " "union { "
"union { " "long long ll ; "
"long long ll ; " "double d ; "
"double d ; " "} ; "
"} ; " "} ; ABC abc ;";
"} ; ABC abc ;"; ASSERT_EQUALS(expected, tok(code, false));
ASSERT_EQUALS(expected, tok(code, false)); }
}
void simplifyStructDecl5() {
const char code[] = "<class T>\n"
"{\n"
" struct {\n"
" typename D4:typename Base<T*>\n"
" };\n"
"};\n";
//don't crash
tok(code, false);
} }


void removeUnwantedKeywords() { void removeUnwantedKeywords() {
Expand Down

0 comments on commit f8578a3

Please sign in to comment.