Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 1 | // TODO(andydavis) Resolve relative path issue w.r.t invoking mlir-opt in RUN |
| 2 | // statements (perhaps through using lit config substitutions). |
| 3 | // |
| 4 | // RUN: %S/../../mlir-opt %s -o - -check-parser-errors |
Jacques Pienaar | bae4051 | 2018-06-24 09:10:36 -0700 | [diff] [blame] | 5 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 6 | // Check different error cases. |
| 7 | // ----- |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 8 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 9 | extfunc @illegaltype(i) // expected-error {{expected type}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 10 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 11 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 12 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 13 | extfunc @nestedtensor(tensor<tensor<i8>>) -> () // expected-error {{expected type}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 14 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 15 | // ----- |
MLIR Team | 718c82f | 2018-07-16 09:45:22 -0700 | [diff] [blame] | 16 | // Test no comma in memref type. |
| 17 | // TODO(andydavis) Fix this test if we decide to allow empty affine map to |
| 18 | // imply identity affine map. |
| 19 | extfunc @memrefs(memref<2x4xi8>) ; expected-error {{expected ',' in memref type}} |
| 20 | |
| 21 | // ----- |
| 22 | // Test no map in memref type. |
| 23 | extfunc @memrefs(memref<2x4xi8, >) ; expected-error {{expected list element}} |
| 24 | |
| 25 | // ----- |
| 26 | // Test non-existent map in memref type. |
| 27 | extfunc @memrefs(memref<2x4xi8, #map7>) ; expected-error {{undefined affine map id 'map7'}} |
| 28 | |
| 29 | // ----- |
| 30 | // Test non hash identifier in memref type. |
| 31 | extfunc @memrefs(memref<2x4xi8, %map7>) ; expected-error {{expected '(' at start of dimensional identifiers list}} |
| 32 | |
| 33 | // ----- |
| 34 | // Test non-existent map in map composition of memref type. |
| 35 | #map0 = (d0, d1) -> (d0, d1) |
| 36 | |
| 37 | extfunc @memrefs(memref<2x4xi8, #map0, #map8>) ; expected-error {{undefined affine map id 'map8'}} |
| 38 | |
| 39 | // ----- |
| 40 | // Test multiple memory space error. |
| 41 | #map0 = (d0, d1) -> (d0, d1) |
| 42 | extfunc @memrefs(memref<2x4xi8, #map0, 1, 2>) ; expected-error {{multiple memory spaces specified in memref type}} |
| 43 | |
| 44 | // ----- |
| 45 | // Test affine map after memory space. |
| 46 | #map0 = (d0, d1) -> (d0, d1) |
| 47 | #map1 = (d0, d1) -> (d0, d1) |
| 48 | |
| 49 | extfunc @memrefs(memref<2x4xi8, #map0, 1, #map1>) ; expected-error {{affine map after memory space in memref type}} |
| 50 | |
| 51 | // ----- |
| 52 | // Test no memory space error. |
| 53 | #map0 = (d0, d1) -> (d0, d1) |
| 54 | extfunc @memrefs(memref<2x4xi8, #map0>) ; expected-error {{expected memory space in memref type}} |
| 55 | |
| 56 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 57 | |
Jacques Pienaar | bae4051 | 2018-06-24 09:10:36 -0700 | [diff] [blame] | 58 | cfgfunc @foo() |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 59 | cfgfunc @bar() // expected-error {{expected '{' in CFG function}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 60 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 61 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 62 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 63 | extfunc missingsigil() -> (i1, affineint, f32) // expected-error {{expected a function identifier like}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 64 | |
| 65 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 66 | // ----- |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 67 | |
| 68 | cfgfunc @bad_branch() { |
| 69 | bb42: |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 70 | br missing // expected-error {{reference to an undefined basic block 'missing'}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 73 | // ----- |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 74 | |
| 75 | cfgfunc @block_redef() { |
| 76 | bb42: |
| 77 | return |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 78 | bb42: // expected-error {{redefinition of block 'bb42'}} |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 79 | return |
| 80 | } |
| 81 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 82 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 83 | |
| 84 | cfgfunc @no_terminator() { |
| 85 | bb40: |
| 86 | return |
| 87 | bb41: |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 88 | bb42: // expected-error {{expected operation name}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 89 | return |
| 90 | } |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 91 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 92 | // ----- |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 93 | |
| 94 | mlfunc @foo() |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 95 | mlfunc @bar() // expected-error {{expected '{' in ML function}} |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 96 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 97 | // ----- |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 98 | |
| 99 | mlfunc @no_return() { |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 100 | } // expected-error {{ML function must end with return statement}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 101 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 102 | // ----- |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 103 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 104 | " // expected-error {{expected}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 105 | " |
| 106 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 107 | // ----- |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 108 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 109 | " // expected-error {{expected}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 110 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 111 | // ----- |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 112 | |
Chris Lattner | 3b2ef76 | 2018-07-18 15:31:25 -0700 | [diff] [blame] | 113 | cfgfunc @bad_op_type() { |
| 114 | bb40: |
| 115 | "foo"() : i32 // expected-error {{expected function type}} |
| 116 | return |
| 117 | } |
| 118 | // ----- |
| 119 | |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 120 | cfgfunc @no_terminator() { |
| 121 | bb40: |
Chris Lattner | 3b2ef76 | 2018-07-18 15:31:25 -0700 | [diff] [blame] | 122 | "foo"() : ()->() |
| 123 | ""() : ()->() // expected-error {{empty operation name is invalid}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 124 | return |
| 125 | } |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 126 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 127 | // ----- |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 128 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 129 | extfunc @illegaltype(i0) // expected-error {{invalid integer width}} |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 130 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 131 | // ----- |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 132 | |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 133 | mlfunc @incomplete_for() { |
| 134 | for |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 135 | } // expected-error {{expected '{' before statement list}} |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 136 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 137 | // ----- |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 138 | |
| 139 | mlfunc @non_statement() { |
Tatiana Shpeisman | 565b964 | 2018-07-16 11:47:09 -0700 | [diff] [blame] | 140 | asd // expected-error {{expected operation name in quotes}} |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 141 | } |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 142 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 143 | // ----- |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 144 | |
Chris Lattner | 21e67f6 | 2018-07-06 10:46:19 -0700 | [diff] [blame] | 145 | cfgfunc @malformed_dim() { |
| 146 | bb42: |
Chris Lattner | 3b2ef76 | 2018-07-18 15:31:25 -0700 | [diff] [blame] | 147 | "dim"(){index: "xyz"} : ()->i32 // expected-error {{'dim' op requires an integer attribute named 'index'}} |
Chris Lattner | 21e67f6 | 2018-07-06 10:46:19 -0700 | [diff] [blame] | 148 | return |
| 149 | } |
| 150 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 151 | // ----- |
Jacques Pienaar | 0bffd86 | 2018-07-11 13:26:23 -0700 | [diff] [blame] | 152 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 153 | #map = (d0) -> (% // expected-error {{invalid SSA name}} |
Jacques Pienaar | 0bffd86 | 2018-07-11 13:26:23 -0700 | [diff] [blame] | 154 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame] | 155 | // ----- |