File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -929,6 +929,30 @@ void no_throw_in_lambda_by_reference_capture(const copy_constructor_throws& a) n
929
929
[&a] {};
930
930
}
931
931
932
+ void throw_in_lambda_init_capture () noexcept {
933
+ // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_lambda_init_capture' which should not throw exceptions
934
+ [a = [] { throw 42 ; return 0 ; }()] {};
935
+ // CHECK-MESSAGES: :[[@LINE-1]]:13: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here
936
+ // CHECK-MESSAGES: :[[@LINE-2]]:34: note: frame #1: function 'throw_in_lambda_init_capture' calls function 'operator()' here
937
+ }
938
+
939
+ void throw_from_nested_lambda () noexcept {
940
+ // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_from_nested_lambda' which should not throw exceptions
941
+ [] { [] { throw 42 ; }(); }();
942
+ // CHECK-MESSAGES: :[[@LINE-1]]:13: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here
943
+ // CHECK-MESSAGES: :[[@LINE-2]]:24: note: frame #1: function 'operator()' calls function 'operator()' here
944
+ // CHECK-MESSAGES: :[[@LINE-3]]:29: note: frame #2: function 'throw_from_nested_lambda' calls function 'operator()' here
945
+ }
946
+
932
947
const auto throw_in_noexcept_lambda = [] () noexcept { throw 42 ; };
933
948
// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: an exception may be thrown in function 'operator()' which should not throw exceptions
934
949
// CHECK-MESSAGES: :[[@LINE-2]]:56: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here
950
+
951
+ void thrower () {
952
+ throw 42 ;
953
+ }
954
+
955
+ const auto indirect_throw_in_noexcept_lambda = [] () noexcept { thrower (); };
956
+ // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: an exception may be thrown in function 'operator()' which should not throw exceptions
957
+ // CHECK-MESSAGES: :[[@LINE-5]]:3: note: frame #0: unhandled exception of type 'int' may be thrown in function 'thrower' here
958
+ // CHECK-MESSAGES: :[[@LINE-3]]:65: note: frame #1: function 'operator()' calls function 'thrower' here
You can’t perform that action at this time.
0 commit comments