1// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
2
3// See http://llvm.org/pr52045
4// UNSUPPORTED: asan
5
6// Check different error cases.
7// -----
8
9func.func @illegaltype(i) // expected-error {{expected non-function type}}
10
11// -----
12
13func.func @illegaltype() {
14  %0 = arith.constant dense<0> : <vector 4 x f32> : vector<4 x f32> // expected-error {{expected non-function type}}
15}
16
17// -----
18
19func.func @nestedtensor(tensor<tensor<i8>>) -> () // expected-error {{invalid tensor element type}}
20
21// -----
22
23// expected-error@+1 {{invalid dimension}}
24#large_dim = tensor<9223372036854775808xf32>
25
26// -----
27
28func.func @illegalmemrefelementtype(memref<?xtensor<i8>>) -> () // expected-error {{invalid memref element type}}
29
30// -----
31
32func.func @illegalunrankedmemrefelementtype(memref<*xtensor<i8>>) -> () // expected-error {{invalid memref element type}}
33
34// -----
35// Test no map in memref type.
36func.func @memrefs(memref<2x4xi8, >) // expected-error {{expected list element}}
37
38// -----
39// Test non-existent map in memref type.
40func.func @memrefs(memref<2x4xi8, #map7>) // expected-error {{undefined symbol alias id 'map7'}}
41
42// -----
43// Test unsupported memory space.
44func.func @memrefs(memref<2x4xi8, i8>) // expected-error {{unsupported memory space Attribute}}
45
46// -----
47// Test non-existent map in map composition of memref type.
48#map0 = affine_map<(d0, d1) -> (d0, d1)>
49
50func.func @memrefs(memref<2x4xi8, #map0, #map8>) // expected-error {{undefined symbol alias id 'map8'}}
51
52// -----
53// Test multiple memory space error.
54#map0 = affine_map<(d0, d1) -> (d0, d1)>
55func.func @memrefs(memref<2x4xi8, #map0, 1, 2>) // expected-error {{multiple memory spaces specified in memref type}}
56
57// -----
58// Test affine map after memory space.
59#map0 = affine_map<(d0, d1) -> (d0, d1)>
60#map1 = affine_map<(d0, d1) -> (d0, d1)>
61
62func.func @memrefs(memref<2x4xi8, #map0, 1, #map1>) // expected-error {{expected memory space to be last in memref type}}
63
64// -----
65// Test dimension mismatch between memref and layout map.
66// The error must be emitted even for the trivial identity layout maps that are
67// dropped in type creation.
68#map0 = affine_map<(d0, d1) -> (d0, d1)>
69func.func @memrefs(memref<42xi8, #map0>) // expected-error {{memref layout mismatch between rank and affine map: 1 != 2}}
70
71// -----
72
73func.func @memref_space_after_strides(memref<42x42xi8, 0, offset: ?, strides: [?, ?]>) // expected-error {{expected memory space to be last in memref type}}
74
75// -----
76
77func.func @memref_stride_missing_colon(memref<42x42xi8, offset ?, strides: [?, ?]>) // expected-error {{expected colon after `offset` keyword}}
78
79// -----
80
81func.func @memref_stride_invalid_offset(memref<42x42xi8, offset: [], strides: [?, ?]>) // expected-error {{invalid offset}}
82
83// -----
84
85func.func @memref_stride_missing_strides(memref<42x42xi8, offset: 0 [?, ?]>) // expected-error {{expected comma after offset value}}
86
87// -----
88
89func.func @memref_stride_missing_strides(memref<42x42xi8, offset: 0, [?, ?]>) // expected-error {{expected `strides` keyword after offset specification}}
90
91// -----
92
93func.func @memref_stride_missing_colon_2(memref<42x42xi8, offset: 0, strides [?, ?]>) // expected-error {{expected colon after `strides` keyword}}
94
95// -----
96
97// expected-error @+1 {{expected '['}}
98func.func @memref_stride_invalid_strides(memref<42x42xi8, offset: 0, strides: ()>)
99
100// -----
101
102func.func @memref_zero_stride(memref<42x42xi8, offset: ?, strides: [0, ?]>) // expected-error {{invalid memref stride}}
103
104// -----
105
106func.func @tensor_encoding_mismatch(%arg0: tensor<8xi32, "enc">) -> (tensor<8xi32>) { // expected-note {{prior use here}}
107  return %arg0: tensor<8xi32> // expected-error {{use of value '%arg0' expects different type than prior uses: 'tensor<8xi32>' vs 'tensor<8xi32, "enc">'}}
108}
109
110// -----
111
112func.func @bad_branch() {
113^bb12:
114  cf.br ^missing  // expected-error {{reference to an undefined block}}
115}
116
117// -----
118
119func.func @block_redef() {
120^bb42:
121  return
122^bb42:        // expected-error {{redefinition of block '^bb42'}}
123  return
124}
125
126// -----
127
128func.func @no_terminator() {   // expected-error {{empty block: expect at least a terminator}}
129^bb40:
130  return
131^bb41:
132^bb42:
133  return
134}
135
136// -----
137
138func.func @block_no_rparen() {
139^bb42 (%bb42 : i32: // expected-error {{expected ')'}}
140  return
141}
142
143// -----
144
145func.func @block_arg_no_ssaid() {
146^bb42 (i32): // expected-error {{expected SSA operand}}
147  return
148}
149
150// -----
151
152func.func @block_arg_no_type() {
153^bb42 (%0): // expected-error {{expected ':' and type for SSA operand}}
154  return
155}
156
157// -----
158
159func.func @block_arg_no_close_paren() {
160^bb42:
161  cf.br ^bb2( // expected-error@+1 {{expected ':'}}
162  return
163}
164
165// -----
166
167func.func @block_first_has_predecessor() {
168// expected-error@-1 {{entry block of region may not have predecessors}}
169^bb42:
170  cf.br ^bb43
171^bb43:
172  cf.br ^bb42
173}
174
175// -----
176
177func.func @no_return() {
178  %x = arith.constant 0 : i32
179  %y = arith.constant 1 : i32  // expected-error {{block with no terminator}}
180}
181
182// -----
183
184func.func @no_terminator() {
185  cf.br ^bb1
186^bb1:
187  %x = arith.constant 0 : i32
188  %y = arith.constant 1 : i32  // expected-error {{block with no terminator}}
189}
190
191// -----
192
193func.func @no_block_arg_enclosing_parens() {
194^bb %x: i32 : // expected-error {{expected ':' after block name}}
195  return
196}
197
198// -----
199
200"       // expected-error {{expected}}
201"
202
203// -----
204
205"       // expected-error {{expected}}
206
207// -----
208
209func.func @bad_op_type() {
210^bb40:
211  "foo"() : i32  // expected-error {{expected function type}}
212  return
213}
214// -----
215
216func.func @no_terminator() {
217^bb40:
218  "foo"() : ()->()
219  ""() : ()->()  // expected-error {{empty operation name is invalid}}
220  return
221}
222
223// -----
224
225func.func @illegaltype(i21312312323120) // expected-error {{invalid integer width}}
226
227// -----
228
229func.func @malformed_for_percent() {
230  affine.for i = 1 to 10 { // expected-error {{expected SSA operand}}
231
232// -----
233
234func.func @malformed_for_equal() {
235  affine.for %i 1 to 10 { // expected-error {{expected '='}}
236
237// -----
238
239func.func @malformed_for_to() {
240  affine.for %i = 1 too 10 { // expected-error {{expected 'to' between bounds}}
241  }
242}
243
244// -----
245
246func.func @incomplete_for() {
247  affine.for %i = 1 to 10 step 2
248}        // expected-error {{expected '{' to begin a region}}
249
250// -----
251
252#map0 = affine_map<(d0) -> (d0 floordiv 4)>
253
254func.func @reference_to_iv_in_bound() {
255  // expected-error@+2 {{region entry argument '%i0' is already in use}}
256  // expected-note@+1 {{previously referenced here}}
257  affine.for %i0 = #map0(%i0) to 10 {
258  }
259}
260
261// -----
262
263func.func @nonconstant_step(%1 : i32) {
264  affine.for %2 = 1 to 5 step %1 { // expected-error {{expected attribute value}}
265
266// -----
267
268func.func @for_negative_stride() {
269  affine.for %i = 1 to 10 step -1
270}        // expected-error@-1 {{expected step to be representable as a positive signed integer}}
271
272// -----
273
274func.func @non_operation() {
275  test.asd   // expected-error {{custom op 'test.asd' is unknown}}
276}
277
278// -----
279
280func.func @invalid_if_conditional2() {
281  affine.for %i = 1 to 10 {
282    affine.if affine_set<(i)[N] : (i >= )>  // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
283  }
284}
285
286// -----
287
288func.func @invalid_if_conditional3() {
289  affine.for %i = 1 to 10 {
290    affine.if affine_set<(i)[N] : (i == 1)> // expected-error {{expected '0' after '=='}}
291  }
292}
293
294// -----
295
296func.func @invalid_if_conditional4() {
297  affine.for %i = 1 to 10 {
298    affine.if affine_set<(i)[N] : (i >= 2)> // expected-error {{expected '0' after '>='}}
299  }
300}
301
302// -----
303
304func.func @invalid_if_conditional5() {
305  affine.for %i = 1 to 10 {
306    affine.if affine_set<(i)[N] : (i <= 0)> // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
307  }
308}
309
310// -----
311
312func.func @invalid_if_conditional6() {
313  affine.for %i = 1 to 10 {
314    affine.if affine_set<(i) : (i)> // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
315  }
316}
317
318// -----
319// TODO: support affine.if (1)?
320func.func @invalid_if_conditional7() {
321  affine.for %i = 1 to 10 {
322    affine.if affine_set<(i) : (1)> // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
323  }
324}
325
326// -----
327
328#map = affine_map<(d0) -> (%  // expected-error {{invalid SSA name}}
329
330// -----
331
332func.func @test() {
333^bb40:
334  %1 = "foo"() : (i32)->i64 // expected-error {{expected 0 operand types but had 1}}
335  return
336}
337
338// -----
339
340func.func @redef() {
341^bb42:
342  %x = "xxx"(){index = 0} : ()->i32 // expected-note {{previously defined here}}
343  %x = "xxx"(){index = 0} : ()->i32 // expected-error {{redefinition of SSA value '%x'}}
344  return
345}
346
347// -----
348
349func.func @undef() {
350^bb42:
351  %x = "xxx"(%y) : (i32)->i32   // expected-error {{use of undeclared SSA value}}
352  return
353}
354
355// -----
356
357func.func @malformed_type(%a : intt) { // expected-error {{expected non-function type}}
358}
359
360// -----
361
362func.func @resulterror() -> i32 {
363^bb42:
364  return    // expected-error {{'func.return' op has 0 operands, but enclosing function (@resulterror) returns 1}}
365}
366
367// -----
368
369func.func @func_resulterror() -> i32 {
370  return // expected-error {{'func.return' op has 0 operands, but enclosing function (@func_resulterror) returns 1}}
371}
372
373// -----
374
375func.func @argError() {
376^bb1(%a: i64):  // expected-note {{previously defined here}}
377  cf.br ^bb2
378^bb2(%a: i64):  // expected-error{{redefinition of SSA value '%a'}}
379  return
380}
381
382// -----
383
384func.func @br_mismatch() {
385^bb0:
386  %0:2 = "foo"() : () -> (i1, i17)
387  // expected-error @+1 {{branch has 2 operands for successor #0, but target block has 1}}
388  cf.br ^bb1(%0#1, %0#0 : i17, i1)
389
390^bb1(%x: i17):
391  return
392}
393
394// -----
395
396func.func @succ_arg_type_mismatch() {
397^bb0:
398  %0 = "getBool"() : () -> i1
399  // expected-error @+1 {{type mismatch for bb argument #0 of successor #0}}
400  cf.br ^bb1(%0 : i1)
401
402^bb1(%x: i32):
403  return
404}
405
406
407// -----
408
409// Test no nested vector.
410func.func @vectors(vector<1 x vector<1xi32>>, vector<2x4xf32>)
411// expected-error@-1 {{vector elements must be int/index/float type}}
412
413// -----
414
415func.func @condbr_notbool() {
416^bb0:
417  %a = "foo"() : () -> i32 // expected-note {{prior use here}}
418  cf.cond_br %a, ^bb0, ^bb0 // expected-error {{use of value '%a' expects different type than prior uses: 'i1' vs 'i32'}}
419}
420
421// -----
422
423func.func @condbr_badtype() {
424^bb0:
425  %c = "foo"() : () -> i1
426  %a = "foo"() : () -> i32
427  cf.cond_br %c, ^bb0(%a, %a : i32, ^bb0) // expected-error {{expected non-function type}}
428}
429
430// -----
431
432func.func @condbr_a_bb_is_not_a_type() {
433^bb0:
434  %c = "foo"() : () -> i1
435  %a = "foo"() : () -> i32
436  cf.cond_br %c, ^bb0(%a, %a : i32, i32), i32 // expected-error {{expected block name}}
437}
438
439// -----
440
441func.func @successors_in_non_terminator(%a : i32, %b : i32) {
442  %c = "arith.addi"(%a, %b)[^bb1] : () -> () // expected-error {{successors in non-terminator}}
443^bb1:
444  return
445}
446
447// -----
448
449func.func @undef() {
450^bb0:
451  %x = "xxx"(%y) : (i32)->i32   // expected-error {{use of undeclared SSA value name}}
452  return
453}
454
455// -----
456
457func.func @undef() {
458  %x = "xxx"(%y) : (i32)->i32   // expected-error {{use of undeclared SSA value name}}
459  return
460}
461
462// -----
463
464func.func @duplicate_induction_var() {
465  affine.for %i = 1 to 10 {   // expected-note {{previously referenced here}}
466    affine.for %i = 1 to 10 { // expected-error {{region entry argument '%i' is already in use}}
467    }
468  }
469  return
470}
471
472// -----
473
474func.func @name_scope_failure() {
475  affine.for %i = 1 to 10 {
476  }
477  "xxx"(%i) : (index)->()   // expected-error {{use of undeclared SSA value name}}
478  return
479}
480
481// -----
482
483func.func @dominance_failure() {
484^bb0:
485  "foo"(%x) : (i32) -> ()    // expected-error {{operand #0 does not dominate this use}}
486  cf.br ^bb1
487^bb1:
488  %x = "bar"() : () -> i32    // expected-note {{operand defined here (op in the same region)}}
489  return
490}
491
492// -----
493
494func.func @dominance_failure() {
495^bb0:
496  "foo"(%x) : (i32) -> ()    // expected-error {{operand #0 does not dominate this use}}
497  %x = "bar"() : () -> i32    // expected-note {{operand defined here (op in the same block)}}
498  cf.br ^bb1
499^bb1:
500  return
501}
502
503// -----
504
505func.func @dominance_failure() {
506  "foo"() ({
507    "foo"(%x) : (i32) -> ()    // expected-error {{operand #0 does not dominate this use}}
508  }) : () -> ()
509  %x = "bar"() : () -> i32    // expected-note {{operand defined here (op in a parent region)}}
510  return
511}
512
513// -----
514
515func.func @dominance_failure() {  //  expected-note {{operand defined as a block argument (block #1 in the same region)}}
516^bb0:
517  cf.br ^bb1(%x : i32)    // expected-error {{operand #0 does not dominate this use}}
518^bb1(%x : i32):
519  return
520}
521
522// -----
523
524func.func @dominance_failure() {  //  expected-note {{operand defined as a block argument (block #1 in a parent region)}}
525^bb0:
526  %f = "foo"() ({
527    "foo"(%x) : (i32) -> ()    // expected-error {{operand #0 does not dominate this use}}
528  }) : () -> (i32)
529  cf.br ^bb1(%f : i32)
530^bb1(%x : i32):
531  return
532}
533
534// -----
535
536func.func @return_type_mismatch() -> i32 {
537  %0 = "foo"() : ()->f32
538  return %0 : f32  // expected-error {{type of return operand 0 ('f32') doesn't match function result type ('i32') in function @return_type_mismatch}}
539}
540
541// -----
542
543func.func @return_inside_loop() {
544  affine.for %i = 1 to 100 {
545    // expected-error@+1 {{'func.return' op expects parent op 'func.func'}}
546    func.return
547  }
548  return
549}
550
551// -----
552
553// expected-error@+1 {{expected three consecutive dots for an ellipsis}}
554func.func @malformed_ellipsis_one(.)
555
556// -----
557
558// expected-error@+1 {{expected three consecutive dots for an ellipsis}}
559func.func @malformed_ellipsis_two(..)
560
561// -----
562
563// expected-error@+1 {{expected non-function type}}
564func.func @func_variadic(...)
565
566// -----
567
568func.func private @redef()  // expected-note {{see existing symbol definition here}}
569func.func private @redef()  // expected-error {{redefinition of symbol named 'redef'}}
570
571// -----
572
573func.func @foo() {
574^bb0:
575  %x = constant @foo : (i32) -> ()  // expected-error {{reference to function with mismatched type}}
576  return
577}
578
579// -----
580
581func.func @undefined_function() {
582^bb0:
583  %x = constant @qux : (i32) -> ()  // expected-error {{reference to undefined function 'qux'}}
584  return
585}
586
587// -----
588
589#map1 = affine_map<(i)[j] -> (i+j)>
590
591func.func @bound_symbol_mismatch(%N : index) {
592  affine.for %i = #map1(%N) to 100 {
593  // expected-error@-1 {{symbol operand count and affine map symbol count must match}}
594  }
595  return
596}
597
598// -----
599
600#map1 = affine_map<(i)[j] -> (i+j)>
601
602func.func @bound_dim_mismatch(%N : index) {
603  affine.for %i = #map1(%N, %N)[%N] to 100 {
604  // expected-error@-1 {{dim operand count and affine map dim count must match}}
605  }
606  return
607}
608
609// -----
610
611func.func @large_bound() {
612  affine.for %i = 1 to 9223372036854775810 {
613  // expected-error@-1 {{integer constant out of range for attribute}}
614  }
615  return
616}
617
618// -----
619
620func.func @max_in_upper_bound(%N : index) {
621  affine.for %i = 1 to max affine_map<(i)->(N, 100)> { //expected-error {{expected attribute value}}
622  }
623  return
624}
625
626// -----
627
628func.func @step_typo() {
629  affine.for %i = 1 to 100 step -- 1 { //expected-error {{expected constant integer}}
630  }
631  return
632}
633
634// -----
635
636func.func @invalid_bound_map(%N : i32) {
637  affine.for %i = 1 to affine_map<(i)->(j)>(%N) { //expected-error {{use of undeclared identifier}}
638  }
639  return
640}
641
642// -----
643
644// expected-error @+1 {{expected '(' in integer set constraint list}}
645#set0 = affine_set<(i)[N, M] : )i >= 0)>
646
647// -----
648#set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
649
650func.func @invalid_if_operands1(%N : index) {
651  affine.for %i = 1 to 10 {
652    affine.if #set0(%i) {
653    // expected-error@-1 {{symbol operand count and integer set symbol count must match}}
654
655// -----
656#set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
657
658func.func @invalid_if_operands2(%N : index) {
659  affine.for %i = 1 to 10 {
660    affine.if #set0()[%N] {
661    // expected-error@-1 {{dim operand count and integer set dim count must match}}
662
663// -----
664#set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
665
666func.func @invalid_if_operands3(%N : index) {
667  affine.for %i = 1 to 10 {
668    affine.if #set0(%i)[%i] {
669    // expected-error@-1 {{operand cannot be used as a symbol}}
670    }
671  }
672  return
673}
674
675// -----
676// expected-error@+1 {{expected '"' in string literal}}
677"J// -----
678func.func @calls(%arg0: i32) {
679  // expected-error@+1 {{expected non-function type}}
680  %z = "casdasda"(%x) : (ppop32) -> i32
681}
682// -----
683// expected-error@+1 {{expected SSA operand}}
684func.func @n(){^b(
685// -----
686
687func.func @elementsattr_non_tensor_type() -> () {
688^bb0:
689  "foo"(){bar = dense<[4]> : i32} : () -> () // expected-error {{elements literal must be a ranked tensor or vector type}}
690}
691
692// -----
693
694func.func @elementsattr_non_ranked() -> () {
695^bb0:
696  "foo"(){bar = dense<[4]> : tensor<?xi32>} : () -> () // expected-error {{elements literal type must have static shape}}
697}
698
699// -----
700
701func.func @elementsattr_shape_mismatch() -> () {
702^bb0:
703  "foo"(){bar = dense<[4]> : tensor<5xi32>} : () -> () // expected-error {{inferred shape of elements literal ([1]) does not match type ([5])}}
704}
705
706// -----
707
708func.func @elementsattr_invalid() -> () {
709^bb0:
710  "foo"(){bar = dense<[4, [5]]> : tensor<2xi32>} : () -> () // expected-error {{tensor literal is invalid; ranks are not consistent between elements}}
711}
712
713// -----
714
715func.func @elementsattr_badtoken() -> () {
716^bb0:
717  "foo"(){bar = dense<[tf_opaque]> : tensor<1xi32>} : () -> () // expected-error {{expected element literal of primitive type}}
718}
719
720// -----
721
722func.func @elementsattr_floattype1() -> () {
723^bb0:
724  // expected-error@+1 {{expected integer elements, but parsed floating-point}}
725  "foo"(){bar = dense<[4.0]> : tensor<1xi32>} : () -> ()
726}
727
728// -----
729
730func.func @elementsattr_floattype1() -> () {
731^bb0:
732  // expected-error@+1 {{expected integer elements, but parsed floating-point}}
733  "foo"(){bar = dense<4.0> : tensor<i32>} : () -> ()
734}
735
736// -----
737
738func.func @elementsattr_floattype2() -> () {
739^bb0:
740  // expected-error@+1 {{expected floating-point elements, but parsed integer}}
741  "foo"(){bar = dense<[4]> : tensor<1xf32>} : () -> ()
742}
743
744// -----
745
746func.func @elementsattr_toolarge1() -> () {
747^bb0:
748  "foo"(){bar = dense<[777]> : tensor<1xi8>} : () -> () // expected-error {{integer constant out of range}}
749}
750
751// -----
752
753// expected-error@+1 {{parsed zero elements, but type ('tensor<i64>') expected at least 1}}
754#attr = dense<> : tensor<i64>
755
756// -----
757
758func.func @elementsattr_toolarge2() -> () {
759^bb0:
760  "foo"(){bar = dense<[-777]> : tensor<1xi8>} : () -> () // expected-error {{integer constant out of range}}
761}
762
763// -----
764
765"foo"(){bar = dense<[()]> : tensor<complex<i64>>} : () -> () // expected-error {{expected element literal of primitive type}}
766
767// -----
768
769"foo"(){bar = dense<[(10)]> : tensor<complex<i64>>} : () -> () // expected-error {{expected ',' between complex elements}}
770
771// -----
772
773"foo"(){bar = dense<[(10,)]> : tensor<complex<i64>>} : () -> () // expected-error {{expected element literal of primitive type}}
774
775// -----
776
777"foo"(){bar = dense<[(10,10]> : tensor<complex<i64>>} : () -> () // expected-error {{expected ')' after complex elements}}
778
779// -----
780
781func.func @elementsattr_malformed_opaque() -> () {
782^bb0:
783  "foo"(){bar = opaque<10, "0xQZz123"> : tensor<1xi8>} : () -> () // expected-error {{expected dialect namespace}}
784}
785
786// -----
787
788func.func @elementsattr_malformed_opaque1() -> () {
789^bb0:
790  "foo"(){bar = opaque<"_", "0xQZz123"> : tensor<1xi8>} : () -> () // expected-error {{expected string containing hex digits starting with `0x`}}
791}
792
793// -----
794
795func.func @elementsattr_malformed_opaque2() -> () {
796^bb0:
797  "foo"(){bar = opaque<"_", "00abc"> : tensor<1xi8>} : () -> () // expected-error {{expected string containing hex digits starting with `0x`}}
798}
799
800// -----
801
802func.func @redundant_signature(%a : i32) -> () {
803^bb0(%b : i32):  // expected-error {{invalid block name in region with named arguments}}
804  return
805}
806
807// -----
808
809func.func @mixed_named_arguments(%a : i32,
810                               f32) -> () {
811    // expected-error @-1 {{expected SSA identifier}}
812  return
813}
814
815// -----
816
817func.func @mixed_named_arguments(f32,
818                               %a : i32) -> () { // expected-error {{expected type instead of SSA identifier}}
819  return
820}
821
822// -----
823
824// This used to crash the parser, but should just error out by interpreting
825// `tensor` as operator rather than as a type.
826func.func @f(f32) {
827^bb0(%a : f32):
828  %18 = arith.cmpi slt, %idx, %idx : index
829  tensor<42 x index  // expected-error {{custom op 'func.tensor' is unknown}}
830  return
831}
832
833// -----
834
835func.func @f(%m : memref<?x?xf32>) {
836  affine.for %i0 = 0 to 42 {
837    // expected-note@+1 {{previously referenced here}}
838    %x = memref.load %m[%i0, %i1] : memref<?x?xf32>
839  }
840  // expected-error@+1 {{region entry argument '%i1' is already in use}}
841  affine.for %i1 = 0 to 42 {
842  }
843  return
844}
845
846// -----
847
848func.func @dialect_type_empty_namespace(!<"">) -> () { // expected-error {{invalid type identifier}}
849  return
850}
851
852// -----
853
854func.func @dialect_type_no_string_type_data(!foo<>) -> () { // expected-error {{expected string literal data in dialect symbol}}
855  return
856}
857
858// -----
859
860func.func @dialect_type_missing_greater(!foo<"") -> () { // expected-error {{expected '>' in dialect symbol}}
861  return
862}
863
864// -----
865
866func.func @type_alias_unknown(!unknown_alias) -> () { // expected-error {{undefined symbol alias id 'unknown_alias'}}
867  return
868}
869
870// -----
871
872// expected-error @+1 {{type names with a '.' are reserved for dialect-defined names}}
873!foo.bar = i32
874
875// -----
876
877!missing_eq_alias type i32 // expected-error {{expected '=' in type alias definition}}
878
879// -----
880
881!missing_kw_type_alias = i32 // expected-error {{expected 'type' in type alias definition}}
882
883// -----
884
885!missing_type_alias = type // expected-error@+1 {{expected non-function type}}
886
887// -----
888
889!redef_alias = type i32
890!redef_alias = type i32 // expected-error {{redefinition of type alias id 'redef_alias'}}
891
892// -----
893
894// Check ill-formed opaque tensor.
895func.func @complex_loops() {
896  affine.for %i1 = 1 to 100 {
897  // expected-error @+1 {{expected '"' in string literal}}
898  "opaqueIntTensor"(){bar = opaque<"_", "0x686]> : tensor<2x1x4xi32>} : () -> ()
899
900// -----
901
902func.func @mi() {
903  // expected-error @+1 {{expected element literal of primitive type}}
904  "fooi64"(){bar = sparse<vector<1xi64>,[,[,1]
905
906// -----
907
908func.func @invalid_tensor_literal() {
909  // expected-error @+1 {{expected 1-d tensor for sparse element values}}
910  "foof16"(){bar = sparse<[[0, 0, 0]],  [[-2.0]]> : vector<1x1x1xf16>} : () -> ()
911
912// -----
913
914func.func @invalid_tensor_literal() {
915  // expected-error @+1 {{expected element literal of primitive type}}
916  "fooi16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0,, [[0, 0, 0]], [-2.0]> : tensor<2x2x2xi16>} : () -> ()
917
918// -----
919
920func.func @invalid_tensor_literal() {
921  // expected-error @+1 {{sparse index #0 is not contained within the value shape, with index=[1, 1], and type='tensor<1x1xi16>'}}
922  "fooi16"(){bar = sparse<1, 10> : tensor<1x1xi16>} : () -> ()
923
924// -----
925
926func.func @invalid_affine_structure() {
927  %c0 = arith.constant 0 : index
928  %idx = affine.apply affine_map<(d0, d1)> (%c0, %c0) // expected-error {{expected '->' or ':'}}
929  return
930}
931
932// -----
933
934func.func @missing_for_max(%arg0: index, %arg1: index, %arg2: memref<100xf32>) {
935  // expected-error @+1 {{lower loop bound affine map with multiple results requires 'max' prefix}}
936  affine.for %i0 = affine_map<()[s]->(0,s-1)>()[%arg0] to %arg1 {
937  }
938  return
939}
940
941// -----
942
943func.func @missing_for_min(%arg0: index, %arg1: index, %arg2: memref<100xf32>) {
944  // expected-error @+1 {{upper loop bound affine map with multiple results requires 'min' prefix}}
945  affine.for %i0 = %arg0 to affine_map<()[s]->(100,s+1)>()[%arg1] {
946  }
947  return
948}
949
950// -----
951
952// expected-error @+1 {{vector types must have positive constant sizes}}
953func.func @zero_vector_type() -> vector<0xi32>
954
955// -----
956
957// expected-error @+1 {{vector types must have positive constant sizes}}
958func.func @zero_in_vector_type() -> vector<1x0xi32>
959
960// -----
961
962// expected-error @+1 {{expected non-function type}}
963func.func @negative_vector_size() -> vector<-1xi32>
964
965// -----
966
967// expected-error @+1 {{expected non-function type}}
968func.func @negative_in_vector_size() -> vector<1x-1xi32>
969
970// -----
971
972// expected-error @+1 {{expected non-function type}}
973func.func @negative_memref_size() -> memref<-1xi32>
974
975// -----
976
977// expected-error @+1 {{expected non-function type}}
978func.func @negative_in_memref_size() -> memref<1x-1xi32>
979
980// -----
981
982// expected-error @+1 {{expected non-function type}}
983func.func @negative_tensor_size() -> tensor<-1xi32>
984
985// -----
986
987// expected-error @+1 {{expected non-function type}}
988func.func @negative_in_tensor_size() -> tensor<1x-1xi32>
989
990// -----
991
992func.func @invalid_nested_dominance() {
993  "test.ssacfg_region"() ({
994    // expected-error @+1 {{operand #0 does not dominate this use}}
995    "foo.use" (%1) : (i32) -> ()
996    cf.br ^bb2
997
998  ^bb2:
999    // expected-note @+1 {{operand defined here}}
1000    %1 = arith.constant 0 : i32
1001    "foo.yield" () : () -> ()
1002  }) : () -> ()
1003  return
1004}
1005
1006// -----
1007
1008// expected-error @+1 {{unbalanced ']' character in pretty dialect name}}
1009func.func @invalid_unknown_type_dialect_name() -> !invalid.dialect<!x@#]!@#>
1010
1011// -----
1012
1013// expected-error @+1 {{@ identifier expected to start with letter or '_'}}
1014func.func @$invalid_function_name()
1015
1016// -----
1017
1018// expected-error @+1 {{arguments may only have dialect attributes}}
1019func.func @invalid_func_arg_attr(i1 {non_dialect_attr = 10})
1020
1021// -----
1022
1023// expected-error @+1 {{results may only have dialect attributes}}
1024func.func @invalid_func_result_attr() -> (i1 {non_dialect_attr = 10})
1025
1026// -----
1027
1028// expected-error @+1 {{expected '<' in tuple type}}
1029func.func @invalid_tuple_missing_less(tuple i32>)
1030
1031// -----
1032
1033// expected-error @+1 {{expected '>' in tuple type}}
1034func.func @invalid_tuple_missing_greater(tuple<i32)
1035
1036// -----
1037
1038// Should not crash because of deletion order here.
1039func.func @invalid_region_dominance() {
1040  "foo.use" (%1) : (i32) -> ()
1041  "foo.region"() ({
1042    %1 = arith.constant 0 : i32  // This value is used outside of the region.
1043    "foo.yield" () : () -> ()
1044  }, {
1045    // expected-error @+1 {{expected operation name in quotes}}
1046    %2 = arith.constant 1 i32  // Syntax error causes region deletion.
1047  }) : () -> ()
1048  return
1049}
1050
1051// -----
1052
1053// Should not crash because of deletion order here.
1054func.func @invalid_region_block() {
1055  "foo.branch"()[^bb2] : () -> ()  // Attempt to jump into the region.
1056
1057^bb1:
1058  "foo.region"() ({
1059    ^bb2:
1060      "foo.yield"() : () -> ()
1061  }, {
1062    // expected-error @+1 {{expected operation name in quotes}}
1063    %2 = arith.constant 1 i32  // Syntax error causes region deletion.
1064  }) : () -> ()
1065}
1066
1067// -----
1068
1069// Should not crash because of deletion order here.
1070func.func @invalid_region_dominance() {
1071  "foo.use" (%1) : (i32) -> ()
1072  "foo.region"() ({
1073    "foo.region"() ({
1074      %1 = arith.constant 0 : i32  // This value is used outside of the region.
1075      "foo.yield" () : () -> ()
1076    }) : () -> ()
1077  }, {
1078    // expected-error @+1 {{expected operation name in quotes}}
1079    %2 = arith.constant 1 i32  // Syntax error causes region deletion.
1080  }) : () -> ()
1081  return
1082}
1083
1084// -----
1085
1086func.func @unfinished_region_list() {
1087  // expected-error@+1 {{expected ')' to end region list}}
1088  "region"() ({},{},{} : () -> ()
1089}
1090
1091// -----
1092
1093func.func @multi_result_missing_count() {
1094  // expected-error@+1 {{expected integer number of results}}
1095  %0: = "foo" () : () -> (i32, i32)
1096  return
1097}
1098
1099// -----
1100
1101func.func @multi_result_zero_count() {
1102  // expected-error@+1 {{expected named operation to have atleast 1 result}}
1103  %0:0 = "foo" () : () -> (i32, i32)
1104  return
1105}
1106
1107// -----
1108
1109func.func @multi_result_invalid_identifier() {
1110  // expected-error@+1 {{expected valid ssa identifier}}
1111  %0, = "foo" () : () -> (i32, i32)
1112  return
1113}
1114
1115// -----
1116
1117func.func @multi_result_mismatch_count() {
1118  // expected-error@+1 {{operation defines 2 results but was provided 1 to bind}}
1119  %0:1 = "foo" () : () -> (i32, i32)
1120  return
1121}
1122
1123// -----
1124
1125func.func @multi_result_mismatch_count() {
1126  // expected-error@+1 {{operation defines 2 results but was provided 3 to bind}}
1127  %0, %1, %3 = "foo" () : () -> (i32, i32)
1128  return
1129}
1130
1131// -----
1132
1133func.func @no_result_with_name() {
1134  // expected-error@+1 {{cannot name an operation with no results}}
1135  %0 = "foo" () : () -> ()
1136  return
1137}
1138
1139// -----
1140
1141func.func @conflicting_names() {
1142  // expected-note@+1 {{previously defined here}}
1143  %foo, %bar  = "foo" () : () -> (i32, i32)
1144
1145  // expected-error@+1 {{redefinition of SSA value '%bar'}}
1146  %bar, %baz  = "foo" () : () -> (i32, i32)
1147  return
1148}
1149
1150// -----
1151
1152func.func @ssa_name_missing_eq() {
1153  // expected-error@+1 {{expected '=' after SSA name}}
1154  %0:2 "foo" () : () -> (i32, i32)
1155  return
1156}
1157
1158// -----
1159
1160// expected-error @+1 {{invalid element type for complex}}
1161func.func @bad_complex(complex<memref<2x4xi8>>)
1162
1163// -----
1164
1165// expected-error @+1 {{expected '<' in complex type}}
1166func.func @bad_complex(complex memref<2x4xi8>>)
1167
1168// -----
1169
1170// expected-error @+1 {{expected '>' in complex type}}
1171func.func @bad_complex(complex<i32)
1172
1173// -----
1174
1175// expected-error @+1 {{attribute names with a '.' are reserved for dialect-defined names}}
1176#foo.attr = i32
1177
1178// -----
1179
1180func.func @invalid_region_dominance() {
1181  "test.ssacfg_region"() ({
1182    // expected-error @+1 {{operand #0 does not dominate this use}}
1183    "foo.use" (%def) : (i32) -> ()
1184    "foo.yield" () : () -> ()
1185  }, {
1186    // expected-note @+1 {{operand defined here}}
1187    %def = "foo.def" () : () -> i32
1188  }) : () -> ()
1189  return
1190}
1191
1192// -----
1193
1194func.func @invalid_region_dominance() {
1195  // expected-note @+1 {{operand defined here}}
1196  %def = "test.ssacfg_region"() ({
1197    // expected-error @+1 {{operand #0 does not dominate this use}}
1198    "foo.use" (%def) : (i32) -> ()
1199    "foo.yield" () : () -> ()
1200  }) : () -> (i32)
1201  return
1202}
1203
1204// -----
1205
1206func.func @hexadecimal_float_leading_minus() {
1207  // expected-error @+1 {{hexadecimal float literal should not have a leading minus}}
1208  "foo"() {value = -0x7fff : f16} : () -> ()
1209}
1210
1211// -----
1212
1213func.func @hexadecimal_float_literal_overflow() {
1214  // expected-error @+1 {{hexadecimal float constant out of range for type}}
1215  "foo"() {value = 0xffffffff : f16} : () -> ()
1216}
1217
1218// -----
1219
1220func.func @decimal_float_literal() {
1221  // expected-error @+2 {{unexpected decimal integer literal for a floating point value}}
1222  // expected-note @+1 {{add a trailing dot to make the literal a float}}
1223  "foo"() {value = 42 : f32} : () -> ()
1224}
1225
1226// -----
1227
1228func.func @float_in_int_tensor() {
1229  // expected-error @+1 {{expected integer elements, but parsed floating-point}}
1230  "foo"() {bar = dense<[42.0, 42]> : tensor<2xi32>} : () -> ()
1231}
1232
1233// -----
1234
1235func.func @float_in_bool_tensor() {
1236  // expected-error @+1 {{expected integer elements, but parsed floating-point}}
1237  "foo"() {bar = dense<[true, 42.0]> : tensor<2xi1>} : () -> ()
1238}
1239
1240// -----
1241
1242func.func @decimal_int_in_float_tensor() {
1243  // expected-error @+1 {{expected floating-point elements, but parsed integer}}
1244  "foo"() {bar = dense<[42, 42.0]> : tensor<2xf32>} : () -> ()
1245}
1246
1247// -----
1248
1249func.func @bool_in_float_tensor() {
1250  // expected-error @+1 {{expected floating-point elements, but parsed integer}}
1251  "foo"() {bar = dense<[42.0, true]> : tensor<2xf32>} : () -> ()
1252}
1253
1254// -----
1255
1256func.func @hexadecimal_float_leading_minus_in_tensor() {
1257  // expected-error @+1 {{hexadecimal float literal should not have a leading minus}}
1258  "foo"() {bar = dense<-0x7FFFFFFF> : tensor<2xf32>} : () -> ()
1259}
1260
1261// -----
1262
1263// Check that we report an error when a value could be parsed, but does not fit
1264// into the specified type.
1265func.func @hexadecimal_float_too_wide_for_type_in_tensor() {
1266  // expected-error @+1 {{hexadecimal float constant out of range for type}}
1267  "foo"() {bar = dense<0x7FF0000000000000> : tensor<2xf32>} : () -> ()
1268}
1269
1270// -----
1271
1272// Check that we report an error when a value is too wide to be parsed.
1273func.func @hexadecimal_float_too_wide_in_tensor() {
1274  // expected-error @+1 {{hexadecimal float constant out of range for type}}
1275  "foo"() {bar = dense<0x7FFFFFF0000000000000> : tensor<2xf32>} : () -> ()
1276}
1277
1278// -----
1279
1280func.func @integer_too_wide_in_tensor() {
1281  // expected-error @+1 {{integer constant out of range for type}}
1282  "foo"() {bar = dense<0xFFFFFFFFFFFFFF> : tensor<2xi16>} : () -> ()
1283}
1284
1285// -----
1286
1287func.func @bool_literal_in_non_bool_tensor() {
1288  // expected-error @+1 {{expected i1 type for 'true' or 'false' values}}
1289  "foo"() {bar = dense<true> : tensor<2xi16>} : () -> ()
1290}
1291
1292// -----
1293
1294// expected-error @+1 {{unbalanced ')' character in pretty dialect name}}
1295func.func @bad_arrow(%arg : !unreg.ptr<(i32)->)
1296
1297// -----
1298
1299func.func @negative_value_in_unsigned_int_attr() {
1300  // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1301  "foo"() {bar = -5 : ui32} : () -> ()
1302}
1303
1304// -----
1305
1306func.func @negative_value_in_unsigned_vector_attr() {
1307  // expected-error @+1 {{expected unsigned integer elements, but parsed negative value}}
1308  "foo"() {bar = dense<[5, -5]> : vector<2xui32>} : () -> ()
1309}
1310
1311// -----
1312
1313func.func @large_bound() {
1314  "test.out_of_range_attribute"() {
1315    // expected-error @+1 {{integer constant out of range for attribute}}
1316    attr = -129 : i8
1317  } : () -> ()
1318  return
1319}
1320
1321// -----
1322
1323func.func @large_bound() {
1324  "test.out_of_range_attribute"() {
1325    // expected-error @+1 {{integer constant out of range for attribute}}
1326    attr = 256 : i8
1327  } : () -> ()
1328  return
1329}
1330
1331// -----
1332
1333func.func @large_bound() {
1334  "test.out_of_range_attribute"() {
1335    // expected-error @+1 {{integer constant out of range for attribute}}
1336    attr = -129 : si8
1337  } : () -> ()
1338  return
1339}
1340
1341// -----
1342
1343func.func @large_bound() {
1344  "test.out_of_range_attribute"() {
1345    // expected-error @+1 {{integer constant out of range for attribute}}
1346    attr = 129 : si8
1347  } : () -> ()
1348  return
1349}
1350
1351// -----
1352
1353func.func @large_bound() {
1354  "test.out_of_range_attribute"() {
1355    // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1356    attr = -1 : ui8
1357  } : () -> ()
1358  return
1359}
1360
1361// -----
1362
1363func.func @large_bound() {
1364  "test.out_of_range_attribute"() {
1365    // expected-error @+1 {{integer constant out of range for attribute}}
1366    attr = 256 : ui8
1367  } : () -> ()
1368  return
1369}
1370
1371// -----
1372
1373func.func @large_bound() {
1374  "test.out_of_range_attribute"() {
1375    // expected-error @+1 {{integer constant out of range for attribute}}
1376    attr = -32769 : i16
1377  } : () -> ()
1378  return
1379}
1380
1381// -----
1382
1383func.func @large_bound() {
1384  "test.out_of_range_attribute"() {
1385    // expected-error @+1 {{integer constant out of range for attribute}}
1386    attr = 65536 : i16
1387  } : () -> ()
1388  return
1389}
1390
1391// -----
1392
1393func.func @large_bound() {
1394  "test.out_of_range_attribute"() {
1395    // expected-error @+1 {{integer constant out of range for attribute}}
1396    attr = -32769 : si16
1397  } : () -> ()
1398  return
1399}
1400
1401// -----
1402
1403func.func @large_bound() {
1404  "test.out_of_range_attribute"() {
1405    // expected-error @+1 {{integer constant out of range for attribute}}
1406    attr = 32768 : si16
1407  } : () -> ()
1408  return
1409}
1410
1411// -----
1412
1413func.func @large_bound() {
1414  "test.out_of_range_attribute"() {
1415    // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1416    attr = -1 : ui16
1417  } : () -> ()
1418  return
1419}
1420
1421// -----
1422
1423func.func @large_bound() {
1424  "test.out_of_range_attribute"() {
1425    // expected-error @+1 {{integer constant out of range for attribute}}
1426    attr = 65536: ui16
1427  } : () -> ()
1428  return
1429}
1430
1431// -----
1432
1433func.func @large_bound() {
1434  "test.out_of_range_attribute"() {
1435    // expected-error @+1 {{integer constant out of range for attribute}}
1436    attr = -2147483649 : i32
1437  } : () -> ()
1438  return
1439}
1440
1441// -----
1442
1443func.func @large_bound() {
1444  "test.out_of_range_attribute"() {
1445    // expected-error @+1 {{integer constant out of range for attribute}}
1446    attr = 4294967296 : i32
1447  } : () -> ()
1448  return
1449}
1450
1451// -----
1452
1453func.func @large_bound() {
1454  "test.out_of_range_attribute"() {
1455    // expected-error @+1 {{integer constant out of range for attribute}}
1456    attr = -2147483649 : si32
1457  } : () -> ()
1458  return
1459}
1460
1461// -----
1462
1463func.func @large_bound() {
1464  "test.out_of_range_attribute"() {
1465    // expected-error @+1 {{integer constant out of range for attribute}}
1466    attr = 2147483648 : si32
1467  } : () -> ()
1468  return
1469}
1470
1471// -----
1472
1473func.func @large_bound() {
1474  "test.out_of_range_attribute"() {
1475    // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1476    attr = -1 : ui32
1477  } : () -> ()
1478  return
1479}
1480
1481// -----
1482
1483func.func @large_bound() {
1484  "test.out_of_range_attribute"() {
1485    // expected-error @+1 {{integer constant out of range for attribute}}
1486    attr = 4294967296 : ui32
1487  } : () -> ()
1488  return
1489}
1490
1491// -----
1492
1493func.func @large_bound() {
1494  "test.out_of_range_attribute"() {
1495    // expected-error @+1 {{integer constant out of range for attribute}}
1496    attr = -9223372036854775809 : i64
1497  } : () -> ()
1498  return
1499}
1500
1501// -----
1502
1503func.func @large_bound() {
1504  "test.out_of_range_attribute"() {
1505    // expected-error @+1 {{integer constant out of range for attribute}}
1506    attr = 18446744073709551616 : i64
1507  } : () -> ()
1508  return
1509}
1510
1511// -----
1512
1513func.func @large_bound() {
1514  "test.out_of_range_attribute"() {
1515    // expected-error @+1 {{integer constant out of range for attribute}}
1516    attr = -9223372036854775809 : si64
1517  } : () -> ()
1518  return
1519}
1520
1521// -----
1522
1523func.func @large_bound() {
1524  "test.out_of_range_attribute"() {
1525    // expected-error @+1 {{integer constant out of range for attribute}}
1526    attr = 9223372036854775808 : si64
1527  } : () -> ()
1528  return
1529}
1530
1531// -----
1532
1533func.func @large_bound() {
1534  "test.out_of_range_attribute"() {
1535    // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1536    attr = -1 : ui64
1537  } : () -> ()
1538  return
1539}
1540
1541// -----
1542
1543func.func @large_bound() {
1544  "test.out_of_range_attribute"() {
1545    // expected-error @+1 {{integer constant out of range for attribute}}
1546    attr = 18446744073709551616 : ui64
1547  } : () -> ()
1548  return
1549}
1550
1551// -----
1552
1553func.func @really_large_bound() {
1554  "test.out_of_range_attribute"() {
1555    // expected-error @+1 {{integer constant out of range for attribute}}
1556    attr = 79228162514264337593543950336 : ui96
1557  } : () -> ()
1558  return
1559}
1560
1561// -----
1562
1563func.func @really_large_bound() {
1564  "test.out_of_range_attribute"() {
1565    // expected-error @+1 {{integer constant out of range for attribute}}
1566    attr = 79228162514264337593543950336 : i96
1567  } : () -> ()
1568  return
1569}
1570
1571// -----
1572
1573func.func @really_large_bound() {
1574  "test.out_of_range_attribute"() {
1575    // expected-error @+1 {{integer constant out of range for attribute}}
1576    attr = 39614081257132168796771975168 : si96
1577  } : () -> ()
1578  return
1579}
1580
1581// -----
1582
1583func.func @duplicate_dictionary_attr_key() {
1584  // expected-error @+1 {{duplicate key 'a' in dictionary attribute}}
1585  "foo.op"() {a, a} : () -> ()
1586}
1587
1588// -----
1589
1590// expected-error @+1 {{attribute 'attr' occurs more than once in the attribute list}}
1591test.format_symbol_name_attr_op @name { attr = "xx" }
1592
1593// -----
1594
1595func.func @forward_reference_type_check() -> (i8) {
1596  cf.br ^bb2
1597
1598^bb1:
1599  // expected-note @+1 {{previously used here with type 'i8'}}
1600  return %1 : i8
1601
1602^bb2:
1603  // expected-error @+1 {{definition of SSA value '%1#0' has type 'f32'}}
1604  %1 = "bar"() : () -> (f32)
1605  cf.br ^bb1
1606}
1607
1608// -----
1609
1610func.func @dominance_error_in_unreachable_op() -> i1 {
1611  %c = arith.constant false
1612  return %c : i1
1613^bb0:
1614  "test.ssacfg_region" () ({ // unreachable
1615    ^bb1:
1616// expected-error @+1 {{operand #0 does not dominate this use}}
1617      %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1618      cf.br ^bb4
1619    ^bb2:
1620      cf.br ^bb2
1621    ^bb4:
1622      %1 = "foo"() : ()->i64   // expected-note {{operand defined here}}
1623  }) : () -> ()
1624  return %c : i1
1625}
1626
1627// -----
1628
1629func.func @invalid_region_dominance_with_dominance_free_regions() {
1630  test.graph_region {
1631    "foo.use" (%1) : (i32) -> ()
1632    "foo.region"() ({
1633      %1 = arith.constant 0 : i32  // This value is used outside of the region.
1634      "foo.yield" () : () -> ()
1635    }, {
1636      // expected-error @+1 {{expected operation name in quotes}}
1637      %2 = arith.constant 1 i32  // Syntax error causes region deletion.
1638    }) : () -> ()
1639  }
1640  return
1641}
1642
1643// -----
1644
1645func.func @foo() {} // expected-error {{expected non-empty function body}}
1646
1647// -----
1648
1649// expected-error@+1 {{expected valid attribute name}}
1650"t"(){""}
1651
1652// -----
1653
1654// expected-error@+2 {{expected ']'}}
1655"f"() { b = [@m:
1656
1657