// RUN: cir-opt %s -verify-diagnostics -split-input-file module { cir.func dso_local @invalid_catch_without_all_or_type() { cir.scope { cir.try { cir.yield // expected-error @below {{'cir.try' expected 'all' or 'type' keyword}} } catch [invalid_keyword { cir.yield } } cir.return } } // ----- module { cir.func dso_local @invalid_catch_rtti_type() { cir.scope { // expected-error @below {{'cir.try' op attribute 'handler_types' failed to satisfy constraint: catch all or unwind or global view array attribute}} cir.try { cir.yield } catch [type #cir.undef] (%eh_token : !cir.eh_token) { cir.yield } } cir.return } } // ----- module { cir.func dso_local @invalid_catch_empty_block() { cir.scope { cir.try { cir.yield } // expected-error @below {{'cir.try' blocks are expected to be explicitly terminated}} catch all (%eh_token : !cir.eh_token) { } } cir.return } } // ----- !s32i = !cir.int module { cir.func dso_local @invalid_catch_not_terminated() { %a = cir.alloca !s32i, !cir.ptr, ["a", init] {alignment = 4 : i64} cir.scope { cir.try { cir.yield } // expected-error @below {{'cir.try' blocks are expected to be explicitly terminated}} catch all (%eh_token : !cir.eh_token) { %tmp_a = cir.load %a : !cir.ptr, !s32i } } cir.return } } // ----- module { cir.func dso_local @invalid_catch_multiple_catch_all() { cir.scope { cir.try { cir.yield } catch all (%eh_token : !cir.eh_token) { cir.yield } // expected-error @below {{op 'cir.try' can't have more than one catch all}} catch all (%eh_token_1 : !cir.eh_token) { cir.yield } } cir.return } } // ----- module { cir.func dso_local @invalid_catch_without_type_info() { cir.scope { cir.try { cir.yield } // expected-error @below {{expected attribute value}} // expected-error @below {{op 'cir.try' expected valid RTTI info attribute}} catch [type] (%eh_token : !cir.eh_token) { cir.yield } } cir.return } } // ----- module { cir.func dso_local @invalid_catch_all_with_type_info() { cir.scope { cir.try { cir.yield } // expected-error @below {{op 'cir.try' catch all dosen't need RTTI info attribute}} catch [all] (%eh_token : !cir.eh_token) { cir.yield } } cir.return } } // ----- !u8i = !cir.int !void = !cir.void module { cir.global "private" constant external @_ZTIi : !cir.ptr cir.func dso_local @catch_handler_missing_begin_catch() { cir.scope { // expected-error @below {{catch handler region must start with 'cir.begin_catch'}} cir.try { cir.yield } catch [type #cir.global_view<@_ZTIi> : !cir.ptr] (%eh_token : !cir.eh_token) { cir.yield } unwind (%eh_token_1 : !cir.eh_token) { cir.resume %eh_token_1 : !cir.eh_token } } cir.return } } // ----- !void = !cir.void module { cir.func dso_local @catch_all_handler_missing_begin_catch() { cir.scope { // expected-error @below {{catch handler region must start with 'cir.begin_catch'}} cir.try { cir.yield } catch all (%eh_token : !cir.eh_token) { cir.yield } } cir.return } } // ----- module { cir.func dso_local @invalid_unwind_with_catch_all() { cir.scope { cir.try { cir.yield } catch all (%eh_token : !cir.eh_token) { cir.yield } // expected-error @below {{op 'cir.try' unwind can't be used with catch all}} unwind (%eh_token_1 : !cir.eh_token) { } } cir.return } }