File tree 2 files changed +34
-15
lines changed 2 files changed +34
-15
lines changed Original file line number Diff line number Diff line change
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
+ };
Original file line number Diff line number Diff line change @@ -32,11 +32,6 @@ void throwing_noexcept() noexcept {
32
32
throw 1 ;
33
33
}
34
34
35
- void throwing_throw_nothing () throw() {
36
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_throw_nothing' which should not throw exceptions
37
- throw 1 ;
38
- }
39
-
40
35
void throw_and_catch () noexcept {
41
36
// CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_and_catch' which should not throw exceptions
42
37
try {
@@ -557,7 +552,9 @@ void implicit_int_thrower() {
557
552
throw 1 ;
558
553
}
559
554
560
- void explicit_int_thrower () throw(int );
555
+ void explicit_int_thrower () noexcept (false ) {
556
+ throw 1 ;
557
+ }
561
558
562
559
void indirect_implicit () noexcept {
563
560
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_implicit' which should not throw exceptions
@@ -676,15 +673,6 @@ struct sub_throws : super_throws {
676
673
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws' which should not throw exceptions
677
674
};
678
675
679
- struct super_throws_again {
680
- super_throws_again () throw (int );
681
- };
682
-
683
- struct sub_throws_again : super_throws_again {
684
- sub_throws_again () noexcept : super_throws_again() {}
685
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws_again' which should not throw exceptions
686
- };
687
-
688
676
struct init_member_throws {
689
677
super_throws s;
690
678
You can’t perform that action at this time.
0 commit comments