blob: 4f67c8e9b79d535902e25a2ce13717d6d773af74 [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 Shpeismanbf079c92018-07-03 17:51:28 -0700133mlfunc @incomplete_for() {
134 for
Chris Lattner3e59f082018-07-14 23:06:24 -0700135} // expected-error {{expected '{' before statement list}}
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -0700136
Chris Lattner3e59f082018-07-14 23:06:24 -0700137// -----
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -0700138
139mlfunc @non_statement() {
Tatiana Shpeisman565b9642018-07-16 11:47:09 -0700140 asd // expected-error {{expected operation name in quotes}}
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -0700141}
Chris Lattner7121b802018-07-04 20:45:39 -0700142
Chris Lattner3e59f082018-07-14 23:06:24 -0700143// -----
Chris Lattner7121b802018-07-04 20:45:39 -0700144
Chris Lattner21e67f62018-07-06 10:46:19 -0700145cfgfunc @malformed_dim() {
146bb42:
Chris Lattner3b2ef762018-07-18 15:31:25 -0700147 "dim"(){index: "xyz"} : ()->i32 // expected-error {{'dim' op requires an integer attribute named 'index'}}
Chris Lattner21e67f62018-07-06 10:46:19 -0700148 return
149}
150
Chris Lattner3e59f082018-07-14 23:06:24 -0700151// -----
Jacques Pienaar0bffd862018-07-11 13:26:23 -0700152
Chris Lattner3e59f082018-07-14 23:06:24 -0700153#map = (d0) -> (% // expected-error {{invalid SSA name}}
Jacques Pienaar0bffd862018-07-11 13:26:23 -0700154
Chris Lattner3e59f082018-07-14 23:06:24 -0700155// -----
Chris Lattner7f9cc272018-07-19 08:35:28 -0700156
157cfgfunc @test() {
158bb40:
159 %1 = "foo"() : (i32)->i64 // expected-error {{expected 0 types in operand list but had 1}}
160 return
161}
162
163
164// -----
165
166cfgfunc @redef() {
167bb42:
168 %x = "dim"(){index: 0} : ()->i32
169 %x = "dim"(){index: 0} : ()->i32 // expected-error {{redefinition of SSA value %x}}
170 return
171}