| 1 |
// RUN: cir-opt %s -verify-diagnostics -split-input-file |
| 2 |
|
| 3 |
module { |
| 4 |
|
| 5 |
cir.func dso_local @invalid_catch_without_all_or_type() { |
| 6 |
cir.scope { |
| 7 |
cir.try { |
| 8 |
cir.yield |
| 9 |
// expected-error @below {{'cir.try' expected 'all' or 'type' keyword}} |
| 10 |
} catch [invalid_keyword { |
| 11 |
cir.yield |
| 12 |
} |
| 13 |
} |
| 14 |
cir.return |
| 15 |
} |
| 16 |
|
| 17 |
} |
| 18 |
|
| 19 |
// ----- |
| 20 |
|
| 21 |
module { |
| 22 |
|
| 23 |
cir.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.yield |
| 28 |
} catch [type #cir.undef] { |
| 29 |
cir.yield |
| 30 |
} |
| 31 |
} |
| 32 |
cir.return |
| 33 |
} |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
// ----- |
| 38 |
|
| 39 |
module { |
| 40 |
|
| 41 |
cir.func dso_local @invalid_catch_empty_block() { |
| 42 |
cir.scope { |
| 43 |
cir.try { |
| 44 |
cir.yield |
| 45 |
} |
| 46 |
// expected-error @below {{'cir.try' handler region shall not be empty}} |
| 47 |
catch all { |
| 48 |
} |
| 49 |
} |
| 50 |
cir.return |
| 51 |
} |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
// ----- |
| 56 |
|
| 57 |
!s32i = !cir.int<s, 32> |
| 58 |
|
| 59 |
module { |
| 60 |
|
| 61 |
cir.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.yield |
| 66 |
} |
| 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>, !s32i |
| 70 |
} |
| 71 |
} |
| 72 |
cir.return |
| 73 |
} |
| 74 |
|
| 75 |
} |
| 76 |
|
| 77 |
// ----- |
| 78 |
|
| 79 |
module { |
| 80 |
|
| 81 |
cir.func dso_local @invalid_catch_multiple_catch_all() { |
| 82 |
cir.scope { |
| 83 |
cir.try { |
| 84 |
cir.yield |
| 85 |
} catch all { |
| 86 |
cir.yield |
| 87 |
} |
| 88 |
// expected-error @below {{op 'cir.try' can't have more than one catch all}} |
| 89 |
catch all { |
| 90 |
cir.yield |
| 91 |
} |
| 92 |
} |
| 93 |
cir.return |
| 94 |
} |
| 95 |
|
| 96 |
} |
| 97 |
|
| 98 |
// ----- |
| 99 |
|
| 100 |
module { |
| 101 |
|
| 102 |
cir.func dso_local @invalid_catch_without_type_info() { |
| 103 |
cir.scope { |
| 104 |
cir.try { |
| 105 |
cir.yield |
| 106 |
} |
| 107 |
// expected-error @below {{expected attribute value}} |
| 108 |
// expected-error @below {{op 'cir.try' expected valid RTTI info attribute}} |
| 109 |
catch [type] { |
| 110 |
cir.yield |
| 111 |
} |
| 112 |
} |
| 113 |
cir.return |
| 114 |
} |
| 115 |
|
| 116 |
} |
| 117 |
|
| 118 |
// ----- |
| 119 |
|
| 120 |
module { |
| 121 |
|
| 122 |
cir.func dso_local @invalid_catch_all_with_type_info() { |
| 123 |
cir.scope { |
| 124 |
cir.try { |
| 125 |
cir.yield |
| 126 |
} |
| 127 |
// expected-error @below {{op 'cir.try' catch all dosen't need RTTI info attribute}} |
| 128 |
catch [all] { |
| 129 |
cir.yield |
| 130 |
} |
| 131 |
} |
| 132 |
cir.return |
| 133 |
} |
| 134 |
|
| 135 |
} |
| 136 |
|
| 137 |
// ----- |
| 138 |
|
| 139 |
module { |
| 140 |
|
| 141 |
cir.func dso_local @invalid_unwind_with_catch_all() { |
| 142 |
cir.scope { |
| 143 |
cir.try { |
| 144 |
cir.yield |
| 145 |
} |
| 146 |
catch all { |
| 147 |
cir.yield |
| 148 |
} |
| 149 |
// expected-error @below {{op 'cir.try' unwind can't be used with catch all}} |
| 150 |
unwind { |
| 151 |
|
| 152 |
} |
| 153 |
} |
| 154 |
cir.return |
| 155 |
} |
| 156 |
|
| 157 |
} |