Fixed ticket #3448 (segmentation fault of cppcheck).

Add testcase related to previous commit (add 'A f(&x);' as declaration of variable).
This commit is contained in:
Edoardo Prezioso 2011-12-31 21:43:06 +01:00
parent b9c796d9f8
commit 38e0e25ce0
2 changed files with 27 additions and 7 deletions

View File

@ -2518,7 +2518,8 @@ void Tokenizer::simplifyDefaultAndDeleteInsideClass()
tok2 = tok2->previous();
if (Token::Match(tok2, "[;{}]") || tok2->isName())
Token::eraseTokens(tok2, end);
tok2 = end;
else
tok2 = end->previous();
}
}
}

View File

@ -3054,6 +3054,7 @@ private:
}
void varid37() {
{
const std::string code = "void blah() {"
" Bar bar(*x);"
"}";
@ -3061,6 +3062,15 @@ private:
"void blah ( ) { Bar bar@1 ( * x ) ; }\n",
tokenizeDebugListing(code));
}
{
const std::string code = "void blah() {"
" Bar bar(&x);"
"}";
ASSERT_EQUALS("\n\n##file 0\n1: "
"void blah ( ) { Bar bar@1 ( & x ) ; }\n",
tokenizeDebugListing(code));
}
}
void varid38() {
const std::string code = "FOO class C;\n";
@ -5171,6 +5181,15 @@ private:
TODO_ASSERT_EQUALS("struct foo { }",
"struct foo { foo ( ) ; } foo :: foo ( ) = delete ;", tokenizeAndStringify(code));
}
//ticket #3448 (segmentation fault)
{
const char *code = "struct A {"
" void bar () = delete;"
"};"
"void baz () = delete;";
ASSERT_EQUALS("struct A { } ; void baz ( ) = delete ;", tokenizeAndStringify(code));
}
}
std::string arraySize_(const std::string &code) {