Fixed #3858 (Throw exception in destructor BUT inside a try-catch shouldn't be reported)
This commit is contained in:
parent
62f92fe253
commit
a37c3144ed
|
@ -42,6 +42,11 @@ void CheckExceptionSafety::destructors()
|
|||
if (j->type == Function::eDestructor && j->functionScope) {
|
||||
// Inspect this destructor..
|
||||
for (const Token *tok = j->functionScope->classStart->next(); tok != j->functionScope->classEnd; tok = tok->next()) {
|
||||
// Skip try blocks
|
||||
if (Token::simpleMatch(tok, "try {")) {
|
||||
tok = tok->next()->link();
|
||||
}
|
||||
|
||||
// throw found within a destructor
|
||||
if (tok->str() == "throw") {
|
||||
destructorsError(tok);
|
||||
|
|
|
@ -82,6 +82,17 @@ private:
|
|||
" throw e;\n"
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Throwing exception in destructor\n", "", errout.str());
|
||||
|
||||
// #3858 - throwing exception in try block in destructor
|
||||
check("class x {\n"
|
||||
" ~x() {\n"
|
||||
" try {\n"
|
||||
" throw e;\n"
|
||||
" } catch (...) {\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void deallocThrow1() {
|
||||
|
|
Loading…
Reference in New Issue