1// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-exception-escape %t -- -- -fexceptions
2
3void 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
8void explicit_int_thrower() throw(int);
9
10void implicit_int_thrower() {
11 throw 5;
12}
13
14void 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
19void 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
24struct super_throws {
25 super_throws() throw(int) { throw 42; }
26};
27
28struct 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};
32

source code of clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp