Skip to content

Commit 8345765

Browse files
Update testexceptionsafety.cpp
1 parent 1fbd066 commit 8345765

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

test/testexceptionsafety.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,21 @@ class TestExceptionSafety : public TestFixture {
356356
check("const char *func() noexcept { return 0; }\n"
357357
"const char *func1() noexcept { try { throw 1; } catch(...) {} return 0; }");
358358
ASSERT_EQUALS("", errout_str());
359+
360+
check("struct A {\n" // #14526
361+
" void f(int = 0, int = 1) { throw 0; }\n"
362+
"};\n"
363+
"void g() noexcept {\n"
364+
" A a;\n"
365+
" a.f();\n"
366+
"}\n"
367+
"void h() noexcept {\n"
368+
" A a;\n"
369+
" a.f(1, 3);\n"
370+
"}\n");
371+
ASSERT_EQUALS("[test.cpp:6:7]: (error) Unhandled exception thrown in function declared not to throw exceptions. [throwInNoexceptFunction]\n"
372+
"[test.cpp:10:7]: (error) Unhandled exception thrown in function declared not to throw exceptions. [throwInNoexceptFunction]\n",
373+
errout_str());
359374
}
360375

361376
void nothrowThrow() {
@@ -518,6 +533,15 @@ class TestExceptionSafety : public TestFixture {
518533
" }\n"
519534
"}\n");
520535
ASSERT_EQUALS("", errout_str());
536+
537+
check("void f(int i) {\n" // #9380
538+
" throw i;\n"
539+
"}\n"
540+
"int main() {\n"
541+
" f(123);\n"
542+
"}\n");
543+
ASSERT_EQUALS("[test.cpp:5:5]: (error) Unhandled exception thrown in function that is an entry point. [throwInEntryPoint]\n",
544+
errout_str());
521545
}
522546
};
523547

0 commit comments

Comments
 (0)