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 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 16 | |
Jacques Pienaar | bae4051 | 2018-06-24 09:10:36 -0700 | [diff] [blame] | 17 | cfgfunc @foo() |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 18 | cfgfunc @bar() // expected-error {{expected '{' in CFG function}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 19 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 20 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 21 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 22 | extfunc missingsigil() -> (i1, affineint, f32) // expected-error {{expected a function identifier like}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 23 | |
24 | |||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 25 | // ----- |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 26 | |
27 | cfgfunc @bad_branch() { | ||||
28 | bb42: | ||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 29 | br missing // expected-error {{reference to an undefined basic block 'missing'}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 30 | } |
31 | |||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 32 | // ----- |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 33 | |
34 | cfgfunc @block_redef() { | ||||
35 | bb42: | ||||
36 | return | ||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 37 | bb42: // expected-error {{redefinition of block 'bb42'}} |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 38 | return |
39 | } | ||||
40 | |||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 41 | // ----- |
Jacques Pienaar | ca4c4a0 | 2018-06-25 08:10:46 -0700 | [diff] [blame] | 42 | |
43 | cfgfunc @no_terminator() { | ||||
44 | bb40: | ||||
45 | return | ||||
46 | bb41: | ||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 47 | bb42: // expected-error {{expected operation name}} |
Chris Lattner | f6d80a0 | 2018-06-24 11:18:29 -0700 | [diff] [blame] | 48 | return |
49 | } | ||||
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 50 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 51 | // ----- |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 52 | |
53 | mlfunc @foo() | ||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 54 | mlfunc @bar() // expected-error {{expected '{' in ML function}} |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 55 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 56 | // ----- |
Tatiana Shpeisman | c96b587 | 2018-06-28 17:02:32 -0700 | [diff] [blame] | 57 | |
58 | mlfunc @no_return() { | ||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 59 | } // expected-error {{ML function must end with return statement}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 60 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 61 | // ----- |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 62 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 63 | " // expected-error {{expected}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 64 | " |
65 | |||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 66 | // ----- |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 67 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 68 | " // expected-error {{expected}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 69 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 70 | // ----- |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 71 | |
72 | cfgfunc @no_terminator() { | ||||
73 | bb40: | ||||
74 | "foo"() | ||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 75 | ""() // expected-error {{empty operation name is invalid}} |
Chris Lattner | ed65a73 | 2018-06-28 20:45:33 -0700 | [diff] [blame] | 76 | return |
77 | } | ||||
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 78 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 79 | // ----- |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 80 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 81 | extfunc @illegaltype(i0) // expected-error {{invalid integer width}} |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 82 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 83 | // ----- |
Chris Lattner | f958bbe | 2018-06-29 22:08:05 -0700 | [diff] [blame] | 84 | |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 85 | mlfunc @incomplete_for() { |
86 | for | ||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 87 | } // expected-error {{expected '{' before statement list}} |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 88 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 89 | // ----- |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 90 | |
91 | mlfunc @non_statement() { | ||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 92 | asd // expected-error {{expected statement}} |
Tatiana Shpeisman | bf079c9 | 2018-07-03 17:51:28 -0700 | [diff] [blame] | 93 | } |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 94 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 95 | // ----- |
Chris Lattner | 7121b80 | 2018-07-04 20:45:39 -0700 | [diff] [blame] | 96 | |
Chris Lattner | 21e67f6 | 2018-07-06 10:46:19 -0700 | [diff] [blame] | 97 | cfgfunc @malformed_dim() { |
98 | bb42: | ||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 99 | "dim"(){index: "xyz"} // expected-error {{'dim' op requires an integer attribute named 'index'}} |
Chris Lattner | 21e67f6 | 2018-07-06 10:46:19 -0700 | [diff] [blame] | 100 | return |
101 | } | ||||
102 | |||||
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 103 | // ----- |
Jacques Pienaar | 0bffd86 | 2018-07-11 13:26:23 -0700 | [diff] [blame] | 104 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 105 | #map = (d0) -> (% // expected-error {{invalid SSA name}} |
Jacques Pienaar | 0bffd86 | 2018-07-11 13:26:23 -0700 | [diff] [blame] | 106 | |
Chris Lattner | 3e59f08 | 2018-07-14 23:06:24 -0700 | [diff] [blame^] | 107 | // ----- |