File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments