File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ // only-wasm32-bare
2+ // compile-flags: -C panic=unwind
3+
4+ #![ crate_type = "lib" ]
5+ #![ feature( core_intrinsics) ]
6+ #![ feature( rustc_attrs) ]
7+
8+ extern {
9+ fn may_panic ( ) ;
10+
11+ #[ rustc_nounwind]
12+ fn log_number ( number : usize ) ;
13+ }
14+
15+ struct LogOnDrop ;
16+
17+ impl Drop for LogOnDrop {
18+ fn drop ( & mut self ) {
19+ unsafe { log_number ( 0 ) ; }
20+ }
21+ }
22+
23+ // CHECK-LABEL: @test_cleanup() {{.*}} @__gxx_wasm_personality_v0
24+ #[ no_mangle]
25+ pub fn test_cleanup ( ) {
26+ let _log_on_drop = LogOnDrop ;
27+ unsafe { may_panic ( ) ; }
28+
29+ // CHECK-NOT: call
30+ // CHECK: invoke void @may_panic()
31+ // CHECK: %cleanuppad = cleanuppad within none []
32+ }
33+
34+ // CHECK-LABEL: @test_rtry() {{.*}} @__gxx_wasm_personality_v0
35+ #[ no_mangle]
36+ pub fn test_rtry ( ) {
37+ unsafe {
38+ core:: intrinsics:: r#try ( |_| {
39+ may_panic ( ) ;
40+ } , core:: ptr:: null_mut ( ) , |data, exception| {
41+ log_number ( data as usize ) ;
42+ log_number ( exception as usize ) ;
43+ } ) ;
44+ }
45+
46+ // CHECK-NOT: call
47+ // CHECK: invoke void @may_panic()
48+ // CHECK: {{.*}} = catchswitch within none [label {{.*}}] unwind to caller
49+ // CHECK: {{.*}} = catchpad within {{.*}} [ptr null]
50+ // CHECK: catchret
51+ }
You can’t perform that action at this time.
0 commit comments