File tree Expand file tree Collapse file tree 5 files changed +49
-21
lines changed Expand file tree Collapse file tree 5 files changed +49
-21
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
77
77
#endif
78
78
extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type ();
79
79
80
+ // GNU extension
81
+ // Calls `terminate` with the current exception being caught. This function is used by GCC when a `noexcept` function
82
+ // throws an exception inside a try/catch block and doesn't catch it.
83
+ extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_call_terminate (void *) throw();
84
+
80
85
// 2.5.4 Rethrowing Exceptions
81
86
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow ();
82
87
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ ___cxa_begin_catch
5
5
___cxa_call_unexpected
6
6
___cxa_current_exception_type
7
7
___cxa_end_catch
8
+ ___cxa_call_terminate
8
9
___cxa_free_dependent_exception
9
10
___cxa_free_exception
10
11
___cxa_get_exception_ptr
Original file line number Diff line number Diff line change @@ -589,6 +589,11 @@ void __cxa_end_catch() {
589
589
}
590
590
}
591
591
592
+ void __cxa_call_terminate (void * unwind_arg) throw () {
593
+ __cxa_begin_catch (unwind_arg);
594
+ std::terminate ();
595
+ }
596
+
592
597
// Note: exception_header may be masquerading as a __cxa_dependent_exception
593
598
// and that's ok. exceptionType is there too.
594
599
// However watch out for foreign exceptions. Return null for them.
Original file line number Diff line number Diff line change 8
8
9
9
// UNSUPPORTED: no-exceptions
10
10
11
- #include < cassert>
12
-
13
- // Clang emits warnings about exceptions of type 'Child' being caught by
14
- // an earlier handler of type 'Base'. Congrats clang, you've just
15
- // diagnosed the behavior under test.
16
- #if defined(__clang__)
17
- #pragma clang diagnostic ignored "-Wexceptions"
18
- #endif
11
+ // Clang and GCC emit warnings about exceptions of type 'Child' being caught by
12
+ // an earlier handler of type 'Base'.
13
+ // ADDITIONAL_COMPILE_FLAGS: -Wno-exceptions
19
14
20
- #if __has_feature(cxx_nullptr)
15
+ #include < cassert >
21
16
22
17
struct A {};
23
18
@@ -124,18 +119,6 @@ void test6()
124
119
}
125
120
}
126
121
127
-
128
- #else
129
-
130
- void test1 () {}
131
- void test2 () {}
132
- void test3 () {}
133
- void test4 () {}
134
- void test5 () {}
135
- void test6 () {}
136
-
137
- #endif
138
-
139
122
int main (int , char **) {
140
123
test1 ();
141
124
test2 ();
Original file line number Diff line number Diff line change
1
+ // ===----------------------------------------------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+
9
+ // We're testing the diagnosed behaviour here.
10
+ // ADDITIONAL_COMPILE_FLAGS: -Wno-exceptions
11
+
12
+ #include < cassert>
13
+ #include < cstdlib>
14
+ #include < exception>
15
+
16
+ #include " test_macros.h"
17
+
18
+ void func () TEST_NOEXCEPT {
19
+ try {
20
+ throw 1 ;
21
+ } catch (float ) {
22
+ }
23
+ }
24
+
25
+ [[noreturn]] void terminate_handler () {
26
+ assert (std::current_exception () != nullptr );
27
+ std::exit (0 );
28
+ }
29
+
30
+ int main (int , char **) {
31
+ std::set_terminate (terminate_handler);
32
+ func ();
33
+ assert (false );
34
+ }
You can’t perform that action at this time.
0 commit comments