blob: b2c74328146c352c6f45e5c328d7372722a1e0e5 [file] [log] [blame]
Chris Lattner3e59f082018-07-14 23:06:24 -07001// 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 Pienaarbae40512018-06-24 09:10:36 -07005
Chris Lattner3e59f082018-07-14 23:06:24 -07006// Check different error cases.
7// -----
Chris Lattnerf6d80a02018-06-24 11:18:29 -07008
Chris Lattner3e59f082018-07-14 23:06:24 -07009extfunc @illegaltype(i) // expected-error {{expected type}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070010
Chris Lattner3e59f082018-07-14 23:06:24 -070011// -----
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070012
Chris Lattner3e59f082018-07-14 23:06:24 -070013extfunc @nestedtensor(tensor<tensor<i8>>) -> () // expected-error {{expected type}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070014
Chris Lattner3e59f082018-07-14 23:06:24 -070015// -----
MLIR Team718c82f2018-07-16 09:45:22 -070016// 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.
19extfunc @memrefs(memref<2x4xi8>) ; expected-error {{expected ',' in memref type}}
20
21// -----
22// Test no map in memref type.
23extfunc @memrefs(memref<2x4xi8, >) ; expected-error {{expected list element}}
24
25// -----
26// Test non-existent map in memref type.
27extfunc @memrefs(memref<2x4xi8, #map7>) ; expected-error {{undefined affine map id 'map7'}}
28
29// -----
30// Test non hash identifier in memref type.
31extfunc @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
37extfunc @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)
42extfunc @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
49extfunc @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)
54extfunc @memrefs(memref<2x4xi8, #map0>) ; expected-error {{expected memory space in memref type}}
55
56// -----
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070057
Jacques Pienaarbae40512018-06-24 09:10:36 -070058cfgfunc @foo()
Chris Lattner3e59f082018-07-14 23:06:24 -070059cfgfunc @bar() // expected-error {{expected '{' in CFG function}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070060
Chris Lattner3e59f082018-07-14 23:06:24 -070061// -----
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070062
Chris Lattner3e59f082018-07-14 23:06:24 -070063extfunc missingsigil() -> (i1, affineint, f32) // expected-error {{expected a function identifier like}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070064
65
Chris Lattner3e59f082018-07-14 23:06:24 -070066// -----
Chris Lattnerf6d80a02018-06-24 11:18:29 -070067
68cfgfunc @bad_branch() {
69bb42:
Chris Lattner3e59f082018-07-14 23:06:24 -070070 br missing // expected-error {{reference to an undefined basic block 'missing'}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070071}
72
Chris Lattner3e59f082018-07-14 23:06:24 -070073// -----
Chris Lattnerf6d80a02018-06-24 11:18:29 -070074
75cfgfunc @block_redef() {
76bb42:
77 return
Chris Lattner3e59f082018-07-14 23:06:24 -070078bb42: // expected-error {{redefinition of block 'bb42'}}
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070079 return
80}
81
Chris Lattner3e59f082018-07-14 23:06:24 -070082// -----
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070083
84cfgfunc @no_terminator() {
85bb40:
86 return
87bb41:
Chris Lattner3e59f082018-07-14 23:06:24 -070088bb42: // expected-error {{expected operation name}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070089 return
90}
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070091
Chris Lattner3e59f082018-07-14 23:06:24 -070092// -----
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070093
94mlfunc @foo()
Chris Lattner3e59f082018-07-14 23:06:24 -070095mlfunc @bar() // expected-error {{expected '{' in ML function}}
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070096
Chris Lattner3e59f082018-07-14 23:06:24 -070097// -----
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070098
99mlfunc @no_return() {
Chris Lattner3e59f082018-07-14 23:06:24 -0700100} // expected-error {{ML function must end with return statement}}
Chris Lattnered65a732018-06-28 20:45:33 -0700101
Chris Lattner3e59f082018-07-14 23:06:24 -0700102// -----
Chris Lattnered65a732018-06-28 20:45:33 -0700103
Chris Lattner3e59f082018-07-14 23:06:24 -0700104" // expected-error {{expected}}
Chris Lattnered65a732018-06-28 20:45:33 -0700105"
106
Chris Lattner3e59f082018-07-14 23:06:24 -0700107// -----
Chris Lattnered65a732018-06-28 20:45:33 -0700108
Chris Lattner3e59f082018-07-14 23:06:24 -0700109" // expected-error {{expected}}
Chris Lattnered65a732018-06-28 20:45:33 -0700110
Chris Lattner3e59f082018-07-14 23:06:24 -0700111// -----
Chris Lattnered65a732018-06-28 20:45:33 -0700112
Chris Lattner3b2ef762018-07-18 15:31:25 -0700113cfgfunc @bad_op_type() {
114bb40:
115 "foo"() : i32 // expected-error {{expected function type}}
116 return
117}
118// -----
119
Chris Lattnered65a732018-06-28 20:45:33 -0700120cfgfunc @no_terminator() {
121bb40:
Chris Lattner3b2ef762018-07-18 15:31:25 -0700122 "foo"() : ()->()
123 ""() : ()->() // expected-error {{empty operation name is invalid}}
Chris Lattnered65a732018-06-28 20:45:33 -0700124 return
125}
Chris Lattnerf958bbe2018-06-29 22:08:05 -0700126
Chris Lattner3e59f082018-07-14 23:06:24 -0700127// -----
Chris Lattnerf958bbe2018-06-29 22:08:05 -0700128
Chris Lattner3e59f082018-07-14 23:06:24 -0700129extfunc @illegaltype(i0) // expected-error {{invalid integer width}}
Chris Lattnerf958bbe2018-06-29 22:08:05 -0700130
Chris Lattner3e59f082018-07-14 23:06:24 -0700131// -----
Chris Lattnerf958bbe2018-06-29 22:08:05 -0700132
Tatiana Shpeisman1da50c42018-07-19 09:52:39 -0700133mlfunc @malformed_for() {
134 for %i = 1 too 10 { // expected-error {{expected 'to' between bounds}}
135 }
136}
137
138// -----
139
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -0700140mlfunc @incomplete_for() {
Tatiana Shpeisman1da50c42018-07-19 09:52:39 -0700141 for %i = 1 to 10 step 2
Chris Lattner3e59f082018-07-14 23:06:24 -0700142} // expected-error {{expected '{' before statement list}}
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -0700143
Chris Lattner3e59f082018-07-14 23:06:24 -0700144// -----
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -0700145
Tatiana Shpeisman1da50c42018-07-19 09:52:39 -0700146mlfunc @nonconstant_step(%1 : i32) {
147 for %2 = 1 to 5 step %1 { // expected-error {{expected non-negative integer for now}}
148
149// -----
150
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -0700151mlfunc @non_statement() {
Tatiana Shpeisman565b9642018-07-16 11:47:09 -0700152 asd // expected-error {{expected operation name in quotes}}
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -0700153}
Chris Lattner7121b802018-07-04 20:45:39 -0700154
Chris Lattner3e59f082018-07-14 23:06:24 -0700155// -----
Chris Lattner7121b802018-07-04 20:45:39 -0700156
Chris Lattner21e67f62018-07-06 10:46:19 -0700157cfgfunc @malformed_dim() {
158bb42:
Chris Lattner3b2ef762018-07-18 15:31:25 -0700159 "dim"(){index: "xyz"} : ()->i32 // expected-error {{'dim' op requires an integer attribute named 'index'}}
Chris Lattner21e67f62018-07-06 10:46:19 -0700160 return
161}
162
Chris Lattner3e59f082018-07-14 23:06:24 -0700163// -----
Jacques Pienaar0bffd862018-07-11 13:26:23 -0700164
Chris Lattner3e59f082018-07-14 23:06:24 -0700165#map = (d0) -> (% // expected-error {{invalid SSA name}}
Jacques Pienaar0bffd862018-07-11 13:26:23 -0700166
Chris Lattner3e59f082018-07-14 23:06:24 -0700167// -----
Chris Lattner7f9cc272018-07-19 08:35:28 -0700168
169cfgfunc @test() {
170bb40:
Chris Lattnerf8cce872018-07-20 09:28:54 -0700171 %1 = "foo"() : (i32)->i64 // expected-error {{expected 0 operand types but had 1}}
Chris Lattner7f9cc272018-07-19 08:35:28 -0700172 return
173}
174
Chris Lattner7f9cc272018-07-19 08:35:28 -0700175// -----
176
177cfgfunc @redef() {
178bb42:
179 %x = "dim"(){index: 0} : ()->i32
180 %x = "dim"(){index: 0} : ()->i32 // expected-error {{redefinition of SSA value %x}}
181 return
Tatiana Shpeisman1da50c42018-07-19 09:52:39 -0700182}
183
184mlfunc @missing_rbrace() {
185 return %a
186mlfunc @d {return} // expected-error {{expected ',' or '}'}}
187
188// -----
189
190mlfunc @malformed_type(%a : intt) { // expected-error {{expected type}}
191}
192
193// -----
194