brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 94df4b6 Raw
158 lines · plain
1// RUN: cir-opt %s -verify-diagnostics -split-input-file2 3module {4 5cir.func dso_local @invalid_catch_without_all_or_type() {6  cir.scope {7    cir.try {8      cir.yield9     // expected-error @below {{'cir.try' expected 'all' or 'type' keyword}}10    } catch [invalid_keyword {11      cir.yield12    }13  }14  cir.return15}16 17}18 19// -----20 21module {22 23cir.func dso_local @invalid_catch_rtti_type() {24  cir.scope {25    // expected-error @below {{'cir.try' op attribute 'handler_types' failed to satisfy constraint: catch all or unwind or global view array attribute}}26    cir.try {27      cir.yield28    } catch [type #cir.undef] {29      cir.yield30    }31  }32  cir.return33}34 35}36 37// -----38 39module {40 41cir.func dso_local @invalid_catch_empty_block() {42  cir.scope {43    cir.try {44      cir.yield45    }46    // expected-error @below {{'cir.try' handler region shall not be empty}}47    catch all {48    }49  }50  cir.return51}52 53}54 55// -----56 57!s32i = !cir.int<s, 32>58 59module {60 61cir.func dso_local @invalid_catch_not_terminated() {62  %a = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init]63  cir.scope {64    cir.try {65      cir.yield66    } 67    // expected-error @below {{'cir.try' blocks are expected to be explicitly terminated}}68    catch all {69       %tmp_a = cir.load %a : !cir.ptr<!s32i>, !s32i70    }71  }72  cir.return73}74 75}76 77// -----78 79module {80 81cir.func dso_local @invalid_catch_multiple_catch_all() {82  cir.scope {83    cir.try {84      cir.yield85    } catch all {86      cir.yield87    } 88    // expected-error @below {{op 'cir.try' can't have more than one catch all}}89    catch all {90      cir.yield91    }92  }93  cir.return94}95 96}97 98// -----99 100module {101 102cir.func dso_local @invalid_catch_without_type_info() {103  cir.scope {104    cir.try {105      cir.yield106    } 107    // expected-error @below {{expected attribute value}}108    // expected-error @below {{op 'cir.try' expected valid RTTI info attribute}}109    catch [type] {110      cir.yield111    }112  }113  cir.return114}115 116}117 118// -----119 120module {121 122cir.func dso_local @invalid_catch_all_with_type_info() {123  cir.scope {124    cir.try {125      cir.yield126    }127    // expected-error @below {{op 'cir.try' catch all dosen't need RTTI info attribute}}128    catch [all] {129      cir.yield130    }131  }132  cir.return133}134 135}136 137// -----138 139module {140 141cir.func dso_local @invalid_unwind_with_catch_all() {142  cir.scope {143    cir.try {144      cir.yield145    }146    catch all {147      cir.yield148    }149    // expected-error @below {{op 'cir.try' unwind can't be used with catch all}}150    unwind {151 152    }153  }154  cir.return155}156 157}158