| 1 |
// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-exception-escape %t -- -- -fexceptions |
| 2 |
|
| 3 |
void throwing_throw_nothing() throw() { |
| 4 |
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_throw_nothing' which should not throw exceptions |
| 5 |
throw 1; |
| 6 |
} |
| 7 |
|
| 8 |
void explicit_int_thrower() throw(int); |
| 9 |
|
| 10 |
void implicit_int_thrower() { |
| 11 |
throw 5; |
| 12 |
} |
| 13 |
|
| 14 |
void indirect_implicit() throw() { |
| 15 |
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_implicit' which should not throw exceptions |
| 16 |
implicit_int_thrower(); |
| 17 |
} |
| 18 |
|
| 19 |
void indirect_explicit() throw() { |
| 20 |
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_explicit' which should not throw exceptions |
| 21 |
explicit_int_thrower(); |
| 22 |
} |
| 23 |
|
| 24 |
struct super_throws { |
| 25 |
super_throws() throw(int) { throw 42; } |
| 26 |
}; |
| 27 |
|
| 28 |
struct sub_throws : super_throws { |
| 29 |
sub_throws() throw() : super_throws() {} |
| 30 |
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws' which should not throw exceptions |
| 31 |
}; |