Skip to content

Commit 999350f

Browse files
Update testexceptionsafety.cpp
1 parent 260532b commit 999350f

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

test/testexceptionsafety.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class TestExceptionSafety : public TestFixture {
5757
TEST_CASE(rethrowNoCurrentException2);
5858
TEST_CASE(rethrowNoCurrentException3);
5959
TEST_CASE(noFunctionCall);
60+
TEST_CASE(entryPoint);
6061
}
6162

6263
struct CheckOptions
@@ -404,7 +405,7 @@ class TestExceptionSafety : public TestFixture {
404405
"{\n"
405406
" f();\n"
406407
"}\n", dinit(CheckOptions, $.inconclusive = true));
407-
ASSERT_EQUALS("", errout_str());
408+
ASSERT_EQUALS("[test.cpp:4:5]: (error) Exception thrown in function that is an entry point. [throwInEntryPoint]\n", errout_str());
408409
}
409410

410411
void unhandledExceptionSpecification3() {
@@ -421,12 +422,16 @@ class TestExceptionSafety : public TestFixture {
421422
"}\n";
422423

423424
check(code, dinit(CheckOptions, $.inconclusive = true));
424-
ASSERT_EQUALS("[test.cpp:3:5] -> [test.cpp:1:6]: (style, inconclusive) Unhandled exception specification when calling function f(). [unhandledExceptionSpecification]\n"
425+
ASSERT_EQUALS("[test.cpp:10:5]: (error) Exception thrown in function that is an entry point. [throwInEntryPoint]\n"
426+
"[test.cpp:3:5] -> [test.cpp:1:6]: (style, inconclusive) Unhandled exception specification when calling function f(). [unhandledExceptionSpecification]\n"
425427
"[test.cpp:6:5] -> [test.cpp:1:6]: (style, inconclusive) Unhandled exception specification when calling function f(). [unhandledExceptionSpecification]\n", errout_str());
426428

427429
const Settings s = settingsBuilder().library("gnu.cfg").build();
428430
check(code, dinit(CheckOptions, $.inconclusive = true, $.s = &s));
429-
ASSERT_EQUALS("", errout_str());
431+
ASSERT_EQUALS("[test.cpp:3:5]: (error) Exception thrown in function that is an entry point. [throwInEntryPoint]\n"
432+
"[test.cpp:6:5]: (error) Exception thrown in function that is an entry point. [throwInEntryPoint]\n"
433+
"[test.cpp:10:5]: (error) Exception thrown in function that is an entry point. [throwInEntryPoint]\n",
434+
errout_str());
430435
}
431436

432437
void nothrowAttributeThrow() {
@@ -490,6 +495,18 @@ class TestExceptionSafety : public TestFixture {
490495
"}\n");
491496
ASSERT_EQUALS("", errout_str());
492497
}
498+
499+
void entryPoint() {
500+
check("void f(int i) {\n" // #14195
501+
" if (i < 2)\n"
502+
" throw 0;\n"
503+
"}\n"
504+
"int main(int argc, char* argv[]) {\n"
505+
" f(argc);\n"
506+
"}\n");
507+
ASSERT_EQUALS("[test.cpp:6:5]: (error) Exception thrown in function that is an entry point. [throwInEntryPoint]\n",
508+
errout_str());
509+
}
493510
};
494511

495512
REGISTER_TEST(TestExceptionSafety)

0 commit comments

Comments
 (0)