1 | // RUN: %check_clang_tidy -std=c++11,c++14,c++17,c++20 %s bugprone-exception-escape %t -- \ |
---|---|
2 | // RUN: -- -fexceptions |
3 | |
4 | void rethrower() { |
5 | throw; |
6 | } |
7 | |
8 | void callsRethrower() { |
9 | rethrower(); |
10 | } |
11 | |
12 | void callsRethrowerNoexcept() noexcept { |
13 | rethrower(); |
14 | } |
15 | |
16 | int throwsAndCallsRethrower() noexcept { |
17 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'throwsAndCallsRethrower' which should not throw exceptions |
18 | try { |
19 | throw 1; |
20 | } catch(...) { |
21 | rethrower(); |
22 | } |
23 | return 1; |
24 | } |
25 | |
26 | int throwsAndCallsCallsRethrower() noexcept { |
27 | // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'throwsAndCallsCallsRethrower' which should not throw exceptions |
28 | try { |
29 | throw 1; |
30 | } catch(...) { |
31 | callsRethrower(); |
32 | } |
33 | return 1; |
34 | } |
35 | |
36 | void rethrowerNoexcept() noexcept { |
37 | throw; |
38 | } |
39 |