1 // RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
3 // See http://llvm.org/pr52045
6 // Check different error cases.
9 func @illegaltype(i) // expected-error {{expected non-function type}}
14 %0 = arith.constant dense<0> : <vector 4 x f32> : vector<4 x f32> // expected-error {{expected non-function type}}
19 func @nestedtensor(tensor<tensor<i8>>) -> () // expected-error {{invalid tensor element type}}
23 // expected-error@+1 {{invalid dimension}}
24 #large_dim = tensor<9223372036854775808xf32>
28 func @illegalmemrefelementtype(memref<?xtensor<i8>>) -> () // expected-error {{invalid memref element type}}
32 func @illegalunrankedmemrefelementtype(memref<*xtensor<i8>>) -> () // expected-error {{invalid memref element type}}
35 // Test no map in memref type.
36 func @memrefs(memref<2x4xi8, >) // expected-error {{expected list element}}
39 // Test non-existent map in memref type.
40 func @memrefs(memref<2x4xi8, #map7>) // expected-error {{undefined symbol alias id 'map7'}}
43 // Test unsupported memory space.
44 func @memrefs(memref<2x4xi8, i8>) // expected-error {{unsupported memory space Attribute}}
47 // Test non-existent map in map composition of memref type.
48 #map0 = affine_map<(d0, d1) -> (d0, d1)>
50 func @memrefs(memref<2x4xi8, #map0, #map8>) // expected-error {{undefined symbol alias id 'map8'}}
53 // Test multiple memory space error.
54 #map0 = affine_map<(d0, d1) -> (d0, d1)>
55 func @memrefs(memref<2x4xi8, #map0, 1, 2>) // expected-error {{multiple memory spaces specified in memref type}}
58 // Test affine map after memory space.
59 #map0 = affine_map<(d0, d1) -> (d0, d1)>
60 #map1 = affine_map<(d0, d1) -> (d0, d1)>
62 func @memrefs(memref<2x4xi8, #map0, 1, #map1>) // expected-error {{expected memory space to be last in memref type}}
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)>
69 func @memrefs(memref<42xi8, #map0>) // expected-error {{memref layout mismatch between rank and affine map: 1 != 2}}
73 func @memref_space_after_strides(memref<42x42xi8, 0, offset: ?, strides: [?, ?]>) // expected-error {{expected memory space to be last in memref type}}
77 func @memref_stride_missing_colon(memref<42x42xi8, offset ?, strides: [?, ?]>) // expected-error {{expected colon after `offset` keyword}}
81 func @memref_stride_invalid_offset(memref<42x42xi8, offset: [], strides: [?, ?]>) // expected-error {{invalid offset}}
85 func @memref_stride_missing_strides(memref<42x42xi8, offset: 0 [?, ?]>) // expected-error {{expected comma after offset value}}
89 func @memref_stride_missing_strides(memref<42x42xi8, offset: 0, [?, ?]>) // expected-error {{expected `strides` keyword after offset specification}}
93 func @memref_stride_missing_colon_2(memref<42x42xi8, offset: 0, strides [?, ?]>) // expected-error {{expected colon after `strides` keyword}}
97 // expected-error @+1 {{expected '['}}
98 func @memref_stride_invalid_strides(memref<42x42xi8, offset: 0, strides: ()>)
102 func @memref_zero_stride(memref<42x42xi8, offset: ?, strides: [0, ?]>) // expected-error {{invalid memref stride}}
106 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">'}}
114 br ^missing // expected-error {{reference to an undefined block}}
119 func @block_redef() {
122 ^bb42: // expected-error {{redefinition of block '^bb42'}}
128 func @no_terminator() { // expected-error {{empty block: expect at least a terminator}}
138 func @block_no_rparen() {
139 ^bb42 (%bb42 : i32: // expected-error {{expected ')' to end argument list}}
145 func @block_arg_no_ssaid() {
146 ^bb42 (i32): // expected-error {{expected SSA operand}}
152 func @block_arg_no_type() {
153 ^bb42 (%0): // expected-error {{expected ':' and type for SSA operand}}
159 func @block_arg_no_close_paren() {
161 br ^bb2( // expected-error@+1 {{expected ':'}}
167 func @block_first_has_predecessor() {
168 // expected-error@-1 {{entry block of region may not have predecessors}}
178 %x = arith.constant 0 : i32
179 %y = arith.constant 1 : i32 // expected-error {{block with no terminator}}
184 func @no_terminator() {
187 %x = arith.constant 0 : i32
188 %y = arith.constant 1 : i32 // expected-error {{block with no terminator}}
194 " // expected-error {{expected}}
199 " // expected-error {{expected}}
203 func @bad_op_type() {
205 "foo"() : i32 // expected-error {{expected function type}}
210 func @no_terminator() {
213 ""() : ()->() // expected-error {{empty operation name is invalid}}
219 func @illegaltype(i21312312323120) // expected-error {{invalid integer width}}
223 func @malformed_for_percent() {
224 affine.for i = 1 to 10 { // expected-error {{expected SSA operand}}
228 func @malformed_for_equal() {
229 affine.for %i 1 to 10 { // expected-error {{expected '='}}
233 func @malformed_for_to() {
234 affine.for %i = 1 too 10 { // expected-error {{expected 'to' between bounds}}
240 func @incomplete_for() {
241 affine.for %i = 1 to 10 step 2
242 } // expected-error {{expected '{' to begin a region}}
246 #map0 = affine_map<(d0) -> (d0 floordiv 4)>
248 func @reference_to_iv_in_bound() {
249 // expected-error@+2 {{region entry argument '%i0' is already in use}}
250 // expected-note@+1 {{previously referenced here}}
251 affine.for %i0 = #map0(%i0) to 10 {
257 func @nonconstant_step(%1 : i32) {
258 affine.for %2 = 1 to 5 step %1 { // expected-error {{expected non-function type}}
262 func @for_negative_stride() {
263 affine.for %i = 1 to 10 step -1
264 } // expected-error@-1 {{expected step to be representable as a positive signed integer}}
268 func @non_operation() {
269 test.asd // expected-error {{custom op 'test.asd' is unknown}}
274 func @invalid_if_conditional2() {
275 affine.for %i = 1 to 10 {
276 affine.if affine_set<(i)[N] : (i >= )> // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
282 func @invalid_if_conditional3() {
283 affine.for %i = 1 to 10 {
284 affine.if affine_set<(i)[N] : (i == 1)> // expected-error {{expected '0' after '=='}}
290 func @invalid_if_conditional4() {
291 affine.for %i = 1 to 10 {
292 affine.if affine_set<(i)[N] : (i >= 2)> // expected-error {{expected '0' after '>='}}
298 func @invalid_if_conditional5() {
299 affine.for %i = 1 to 10 {
300 affine.if affine_set<(i)[N] : (i <= 0)> // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
306 func @invalid_if_conditional6() {
307 affine.for %i = 1 to 10 {
308 affine.if affine_set<(i) : (i)> // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
313 // TODO: support affine.if (1)?
314 func @invalid_if_conditional7() {
315 affine.for %i = 1 to 10 {
316 affine.if affine_set<(i) : (1)> // expected-error {{expected '== 0' or '>= 0' at end of affine constraint}}
322 #map = affine_map<(d0) -> (% // expected-error {{invalid SSA name}}
328 %1 = "foo"() : (i32)->i64 // expected-error {{expected 0 operand types but had 1}}
336 %x = "xxx"(){index = 0} : ()->i32 // expected-note {{previously defined here}}
337 %x = "xxx"(){index = 0} : ()->i32 // expected-error {{redefinition of SSA value '%x'}}
345 %x = "xxx"(%y) : (i32)->i32 // expected-error {{use of undeclared SSA value}}
351 func @malformed_type(%a : intt) { // expected-error {{expected non-function type}}
356 func @resulterror() -> i32 {
358 return // expected-error {{'std.return' op has 0 operands, but enclosing function (@resulterror) returns 1}}
363 func @func_resulterror() -> i32 {
364 return // expected-error {{'std.return' op has 0 operands, but enclosing function (@func_resulterror) returns 1}}
370 ^bb1(%a: i64): // expected-note {{previously defined here}}
372 ^bb2(%a: i64): // expected-error{{redefinition of SSA value '%a'}}
378 func @br_mismatch() {
380 %0:2 = "foo"() : () -> (i1, i17)
381 // expected-error @+1 {{branch has 2 operands for successor #0, but target block has 1}}
382 br ^bb1(%0#1, %0#0 : i17, i1)
390 func @succ_arg_type_mismatch() {
392 %0 = "getBool"() : () -> i1
393 // expected-error @+1 {{type mismatch for bb argument #0 of successor #0}}
403 // Test no nested vector.
404 func @vectors(vector<1 x vector<1xi32>>, vector<2x4xf32>)
405 // expected-error@-1 {{vector elements must be int/index/float type}}
409 func @condbr_notbool() {
411 %a = "foo"() : () -> i32 // expected-note {{prior use here}}
412 cond_br %a, ^bb0, ^bb0 // expected-error {{use of value '%a' expects different type than prior uses: 'i1' vs 'i32'}}
417 func @condbr_badtype() {
419 %c = "foo"() : () -> i1
420 %a = "foo"() : () -> i32
421 cond_br %c, ^bb0(%a, %a : i32, ^bb0) // expected-error {{expected non-function type}}
426 func @condbr_a_bb_is_not_a_type() {
428 %c = "foo"() : () -> i1
429 %a = "foo"() : () -> i32
430 cond_br %c, ^bb0(%a, %a : i32, i32), i32 // expected-error {{expected block name}}
435 func @successors_in_non_terminator(%a : i32, %b : i32) {
436 %c = "arith.addi"(%a, %b)[^bb1] : () -> () // expected-error {{successors in non-terminator}}
445 %x = "xxx"(%y) : (i32)->i32 // expected-error {{use of undeclared SSA value name}}
452 %x = "xxx"(%y) : (i32)->i32 // expected-error {{use of undeclared SSA value name}}
458 func @duplicate_induction_var() {
459 affine.for %i = 1 to 10 { // expected-note {{previously referenced here}}
460 affine.for %i = 1 to 10 { // expected-error {{region entry argument '%i' is already in use}}
468 func @name_scope_failure() {
469 affine.for %i = 1 to 10 {
471 "xxx"(%i) : (index)->() // expected-error {{use of undeclared SSA value name}}
477 func @dominance_failure() {
479 "foo"(%x) : (i32) -> () // expected-error {{operand #0 does not dominate this use}}
482 %x = "bar"() : () -> i32 // expected-note {{operand defined here (op in the same region)}}
488 func @dominance_failure() {
490 "foo"(%x) : (i32) -> () // expected-error {{operand #0 does not dominate this use}}
491 %x = "bar"() : () -> i32 // expected-note {{operand defined here (op in the same block)}}
499 func @dominance_failure() {
501 "foo"(%x) : (i32) -> () // expected-error {{operand #0 does not dominate this use}}
503 %x = "bar"() : () -> i32 // expected-note {{operand defined here (op in a parent region)}}
509 func @dominance_failure() { // expected-note {{operand defined as a block argument (block #1 in the same region)}}
511 br ^bb1(%x : i32) // expected-error {{operand #0 does not dominate this use}}
518 func @dominance_failure() { // expected-note {{operand defined as a block argument (block #1 in a parent region)}}
521 "foo"(%x) : (i32) -> () // expected-error {{operand #0 does not dominate this use}}
530 func @return_type_mismatch() -> i32 {
531 %0 = "foo"() : ()->f32
532 return %0 : f32 // expected-error {{type of return operand 0 ('f32') doesn't match function result type ('i32') in function @return_type_mismatch}}
537 func @return_inside_loop() {
538 affine.for %i = 1 to 100 {
539 // expected-error@-1 {{op expects regions to end with 'affine.yield', found 'std.return'}}
540 // expected-note@-2 {{in custom textual format, the absence of terminator implies}}
548 // expected-error@+1 {{expected three consecutive dots for an ellipsis}}
549 func @malformed_ellipsis_one(.)
553 // expected-error@+1 {{expected three consecutive dots for an ellipsis}}
554 func @malformed_ellipsis_two(..)
558 // expected-error@+1 {{expected non-function type}}
559 func @func_variadic(...)
563 func @redef() // expected-note {{see existing symbol definition here}}
564 func @redef() // expected-error {{redefinition of symbol named 'redef'}}
570 %x = constant @foo : (i32) -> () // expected-error {{reference to function with mismatched type}}
576 func @undefined_function() {
578 %x = constant @qux : (i32) -> () // expected-error {{reference to undefined function 'qux'}}
584 #map1 = affine_map<(i)[j] -> (i+j)>
586 func @bound_symbol_mismatch(%N : index) {
587 affine.for %i = #map1(%N) to 100 {
588 // expected-error@-1 {{symbol operand count and affine map symbol count must match}}
595 #map1 = affine_map<(i)[j] -> (i+j)>
597 func @bound_dim_mismatch(%N : index) {
598 affine.for %i = #map1(%N, %N)[%N] to 100 {
599 // expected-error@-1 {{dim operand count and affine map dim count must match}}
606 func @large_bound() {
607 affine.for %i = 1 to 9223372036854775810 {
608 // expected-error@-1 {{integer constant out of range for attribute}}
615 func @max_in_upper_bound(%N : index) {
616 affine.for %i = 1 to max affine_map<(i)->(N, 100)> { //expected-error {{expected non-function type}}
624 affine.for %i = 1 to 100 step -- 1 { //expected-error {{expected constant integer}}
631 func @invalid_bound_map(%N : i32) {
632 affine.for %i = 1 to affine_map<(i)->(j)>(%N) { //expected-error {{use of undeclared identifier}}
639 // expected-error @+1 {{expected '(' in integer set constraint list}}
640 #set0 = affine_set<(i)[N, M] : )i >= 0)>
643 #set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
645 func @invalid_if_operands1(%N : index) {
646 affine.for %i = 1 to 10 {
647 affine.if #set0(%i) {
648 // expected-error@-1 {{symbol operand count and integer set symbol count must match}}
651 #set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
653 func @invalid_if_operands2(%N : index) {
654 affine.for %i = 1 to 10 {
655 affine.if #set0()[%N] {
656 // expected-error@-1 {{dim operand count and integer set dim count must match}}
659 #set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
661 func @invalid_if_operands3(%N : index) {
662 affine.for %i = 1 to 10 {
663 affine.if #set0(%i)[%i] {
664 // expected-error@-1 {{operand cannot be used as a symbol}}
671 // expected-error@+1 {{expected '"' in string literal}}
673 func @calls(%arg0: i32) {
674 // expected-error@+1 {{expected non-function type}}
675 %z = "casdasda"(%x) : (ppop32) -> i32
678 // expected-error@+2 {{expected SSA operand}}
682 func @elementsattr_non_tensor_type() -> () {
684 "foo"(){bar = dense<[4]> : i32} : () -> () // expected-error {{elements literal must be a ranked tensor or vector type}}
689 func @elementsattr_non_ranked() -> () {
691 "foo"(){bar = dense<[4]> : tensor<?xi32>} : () -> () // expected-error {{elements literal type must have static shape}}
696 func @elementsattr_shape_mismatch() -> () {
698 "foo"(){bar = dense<[4]> : tensor<5xi32>} : () -> () // expected-error {{inferred shape of elements literal ([1]) does not match type ([5])}}
703 func @elementsattr_invalid() -> () {
705 "foo"(){bar = dense<[4, [5]]> : tensor<2xi32>} : () -> () // expected-error {{tensor literal is invalid; ranks are not consistent between elements}}
710 func @elementsattr_badtoken() -> () {
712 "foo"(){bar = dense<[tf_opaque]> : tensor<1xi32>} : () -> () // expected-error {{expected element literal of primitive type}}
717 func @elementsattr_floattype1() -> () {
719 // expected-error@+1 {{expected integer elements, but parsed floating-point}}
720 "foo"(){bar = dense<[4.0]> : tensor<1xi32>} : () -> ()
725 func @elementsattr_floattype1() -> () {
727 // expected-error@+1 {{expected integer elements, but parsed floating-point}}
728 "foo"(){bar = dense<4.0> : tensor<i32>} : () -> ()
733 func @elementsattr_floattype2() -> () {
735 // expected-error@+1 {{expected floating-point elements, but parsed integer}}
736 "foo"(){bar = dense<[4]> : tensor<1xf32>} : () -> ()
741 func @elementsattr_toolarge1() -> () {
743 "foo"(){bar = dense<[777]> : tensor<1xi8>} : () -> () // expected-error {{integer constant out of range}}
748 // expected-error@+1 {{parsed zero elements, but type ('tensor<i64>') expected at least 1}}
749 #attr = dense<> : tensor<i64>
753 func @elementsattr_toolarge2() -> () {
755 "foo"(){bar = dense<[-777]> : tensor<1xi8>} : () -> () // expected-error {{integer constant out of range}}
760 "foo"(){bar = dense<[()]> : tensor<complex<i64>>} : () -> () // expected-error {{expected element literal of primitive type}}
764 "foo"(){bar = dense<[(10)]> : tensor<complex<i64>>} : () -> () // expected-error {{expected ',' between complex elements}}
768 "foo"(){bar = dense<[(10,)]> : tensor<complex<i64>>} : () -> () // expected-error {{expected element literal of primitive type}}
772 "foo"(){bar = dense<[(10,10]> : tensor<complex<i64>>} : () -> () // expected-error {{expected ')' after complex elements}}
776 func @elementsattr_malformed_opaque() -> () {
778 "foo"(){bar = opaque<10, "0xQZz123"> : tensor<1xi8>} : () -> () // expected-error {{expected dialect namespace}}
783 func @elementsattr_malformed_opaque1() -> () {
785 "foo"(){bar = opaque<"_", "0xQZz123"> : tensor<1xi8>} : () -> () // expected-error {{expected string containing hex digits starting with `0x`}}
790 func @elementsattr_malformed_opaque2() -> () {
792 "foo"(){bar = opaque<"_", "00abc"> : tensor<1xi8>} : () -> () // expected-error {{expected string containing hex digits starting with `0x`}}
797 func @redundant_signature(%a : i32) -> () {
798 ^bb0(%b : i32): // expected-error {{invalid block name in region with named arguments}}
804 func @mixed_named_arguments(%a : i32,
806 // expected-error @-1 {{expected SSA identifier}}
812 func @mixed_named_arguments(f32,
813 %a : i32) -> () { // expected-error {{expected type instead of SSA identifier}}
819 // This used to crash the parser, but should just error out by interpreting
820 // `tensor` as operator rather than as a type.
823 %18 = arith.cmpi slt, %idx, %idx : index
824 tensor<42 x index // expected-error {{custom op 'tensor' is unknown}}
830 func @f(%m : memref<?x?xf32>) {
831 affine.for %i0 = 0 to 42 {
832 // expected-note@+1 {{previously referenced here}}
833 %x = memref.load %m[%i0, %i1] : memref<?x?xf32>
835 // expected-error@+1 {{region entry argument '%i1' is already in use}}
836 affine.for %i1 = 0 to 42 {
843 func @dialect_type_empty_namespace(!<"">) -> () { // expected-error {{invalid type identifier}}
849 func @dialect_type_no_string_type_data(!foo<>) -> () { // expected-error {{expected string literal data in dialect symbol}}
855 func @dialect_type_missing_greater(!foo<"") -> () { // expected-error {{expected '>' in dialect symbol}}
861 func @type_alias_unknown(!unknown_alias) -> () { // expected-error {{undefined symbol alias id 'unknown_alias'}}
867 // expected-error @+1 {{type names with a '.' are reserved for dialect-defined names}}
872 !missing_eq_alias type i32 // expected-error {{expected '=' in type alias definition}}
876 !missing_kw_type_alias = i32 // expected-error {{expected 'type' in type alias definition}}
880 !missing_type_alias = type // expected-error@+2 {{expected non-function type}}
884 !redef_alias = type i32
885 !redef_alias = type i32 // expected-error {{redefinition of type alias id 'redef_alias'}}
889 // Check ill-formed opaque tensor.
890 func @complex_loops() {
891 affine.for %i1 = 1 to 100 {
892 // expected-error @+1 {{expected '"' in string literal}}
893 "opaqueIntTensor"(){bar = opaque<"_", "0x686]> : tensor<2x1x4xi32>} : () -> ()
898 // expected-error @+1 {{expected element literal of primitive type}}
899 "fooi64"(){bar = sparse<vector<1xi64>,[,[,1]
903 func @invalid_tensor_literal() {
904 // expected-error @+1 {{expected 1-d tensor for sparse element values}}
905 "foof16"(){bar = sparse<[[0, 0, 0]], [[-2.0]]> : vector<1x1x1xf16>} : () -> ()
909 func @invalid_tensor_literal() {
910 // expected-error @+1 {{expected element literal of primitive type}}
911 "fooi16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0,, [[0, 0, 0]], [-2.0]> : tensor<2x2x2xi16>} : () -> ()
915 func @invalid_tensor_literal() {
916 // expected-error @+1 {{sparse index #0 is not contained within the value shape, with index=[1, 1], and type='tensor<1x1xi16>'}}
917 "fooi16"(){bar = sparse<1, 10> : tensor<1x1xi16>} : () -> ()
921 func @invalid_affine_structure() {
922 %c0 = arith.constant 0 : index
923 %idx = affine.apply affine_map<(d0, d1)> (%c0, %c0) // expected-error {{expected '->' or ':'}}
929 func @missing_for_max(%arg0: index, %arg1: index, %arg2: memref<100xf32>) {
930 // expected-error @+1 {{lower loop bound affine map with multiple results requires 'max' prefix}}
931 affine.for %i0 = affine_map<()[s]->(0,s-1)>()[%arg0] to %arg1 {
938 func @missing_for_min(%arg0: index, %arg1: index, %arg2: memref<100xf32>) {
939 // expected-error @+1 {{upper loop bound affine map with multiple results requires 'min' prefix}}
940 affine.for %i0 = %arg0 to affine_map<()[s]->(100,s+1)>()[%arg1] {
947 // expected-error @+1 {{vector types must have positive constant sizes}}
948 func @zero_vector_type() -> vector<0xi32>
952 // expected-error @+1 {{vector types must have positive constant sizes}}
953 func @zero_in_vector_type() -> vector<1x0xi32>
957 // expected-error @+1 {{expected non-function type}}
958 func @negative_vector_size() -> vector<-1xi32>
962 // expected-error @+1 {{expected non-function type}}
963 func @negative_in_vector_size() -> vector<1x-1xi32>
967 // expected-error @+1 {{expected non-function type}}
968 func @negative_memref_size() -> memref<-1xi32>
972 // expected-error @+1 {{expected non-function type}}
973 func @negative_in_memref_size() -> memref<1x-1xi32>
977 // expected-error @+1 {{expected non-function type}}
978 func @negative_tensor_size() -> tensor<-1xi32>
982 // expected-error @+1 {{expected non-function type}}
983 func @negative_in_tensor_size() -> tensor<1x-1xi32>
987 func @invalid_nested_dominance() {
988 "test.ssacfg_region"() ({
989 // expected-error @+1 {{operand #0 does not dominate this use}}
990 "foo.use" (%1) : (i32) -> ()
994 // expected-note @+1 {{operand defined here}}
995 %1 = arith.constant 0 : i32
996 "foo.yield" () : () -> ()
1003 // expected-error @+1 {{unbalanced ']' character in pretty dialect name}}
1004 func @invalid_unknown_type_dialect_name() -> !invalid.dialect<!x@#]!@#>
1008 // expected-error @+1 {{@ identifier expected to start with letter or '_'}}
1009 func @$invalid_function_name()
1013 // expected-error @+1 {{arguments may only have dialect attributes}}
1014 func @invalid_func_arg_attr(i1 {non_dialect_attr = 10})
1018 // expected-error @+1 {{results may only have dialect attributes}}
1019 func @invalid_func_result_attr() -> (i1 {non_dialect_attr = 10})
1023 // expected-error @+1 {{expected '<' in tuple type}}
1024 func @invalid_tuple_missing_less(tuple i32>)
1028 // expected-error @+1 {{expected '>' in tuple type}}
1029 func @invalid_tuple_missing_greater(tuple<i32)
1033 // Should not crash because of deletion order here.
1034 func @invalid_region_dominance() {
1035 "foo.use" (%1) : (i32) -> ()
1037 %1 = arith.constant 0 : i32 // This value is used outside of the region.
1038 "foo.yield" () : () -> ()
1040 // expected-error @+1 {{expected operation name in quotes}}
1041 %2 = arith.constant 1 i32 // Syntax error causes region deletion.
1048 // Should not crash because of deletion order here.
1049 func @invalid_region_block() {
1050 "foo.branch"()[^bb2] : () -> () // Attempt to jump into the region.
1055 "foo.yield"() : () -> ()
1057 // expected-error @+1 {{expected operation name in quotes}}
1058 %2 = arith.constant 1 i32 // Syntax error causes region deletion.
1064 // Should not crash because of deletion order here.
1065 func @invalid_region_dominance() {
1066 "foo.use" (%1) : (i32) -> ()
1069 %1 = arith.constant 0 : i32 // This value is used outside of the region.
1070 "foo.yield" () : () -> ()
1073 // expected-error @+1 {{expected operation name in quotes}}
1074 %2 = arith.constant 1 i32 // Syntax error causes region deletion.
1081 func @unfinished_region_list() {
1082 // expected-error@+1 {{expected ')' to end region list}}
1083 "region"() ({},{},{} : () -> ()
1088 func @multi_result_missing_count() {
1089 // expected-error@+1 {{expected integer number of results}}
1090 %0: = "foo" () : () -> (i32, i32)
1096 func @multi_result_zero_count() {
1097 // expected-error@+1 {{expected named operation to have atleast 1 result}}
1098 %0:0 = "foo" () : () -> (i32, i32)
1104 func @multi_result_invalid_identifier() {
1105 // expected-error@+1 {{expected valid ssa identifier}}
1106 %0, = "foo" () : () -> (i32, i32)
1112 func @multi_result_mismatch_count() {
1113 // expected-error@+1 {{operation defines 2 results but was provided 1 to bind}}
1114 %0:1 = "foo" () : () -> (i32, i32)
1120 func @multi_result_mismatch_count() {
1121 // expected-error@+1 {{operation defines 2 results but was provided 3 to bind}}
1122 %0, %1, %3 = "foo" () : () -> (i32, i32)
1128 func @no_result_with_name() {
1129 // expected-error@+1 {{cannot name an operation with no results}}
1130 %0 = "foo" () : () -> ()
1136 func @conflicting_names() {
1137 // expected-note@+1 {{previously defined here}}
1138 %foo, %bar = "foo" () : () -> (i32, i32)
1140 // expected-error@+1 {{redefinition of SSA value '%bar'}}
1141 %bar, %baz = "foo" () : () -> (i32, i32)
1147 func @ssa_name_missing_eq() {
1148 // expected-error@+1 {{expected '=' after SSA name}}
1149 %0:2 "foo" () : () -> (i32, i32)
1155 // expected-error @+1 {{invalid element type for complex}}
1156 func @bad_complex(complex<memref<2x4xi8>>)
1160 // expected-error @+1 {{expected '<' in complex type}}
1161 func @bad_complex(complex memref<2x4xi8>>)
1165 // expected-error @+1 {{expected '>' in complex type}}
1166 func @bad_complex(complex<i32)
1170 // expected-error @+1 {{attribute names with a '.' are reserved for dialect-defined names}}
1175 func @invalid_region_dominance() {
1176 "test.ssacfg_region"() ({
1177 // expected-error @+1 {{operand #0 does not dominate this use}}
1178 "foo.use" (%def) : (i32) -> ()
1179 "foo.yield" () : () -> ()
1181 // expected-note @+1 {{operand defined here}}
1182 %def = "foo.def" () : () -> i32
1189 func @invalid_region_dominance() {
1190 // expected-note @+1 {{operand defined here}}
1191 %def = "test.ssacfg_region"() ({
1192 // expected-error @+1 {{operand #0 does not dominate this use}}
1193 "foo.use" (%def) : (i32) -> ()
1194 "foo.yield" () : () -> ()
1201 func @hexadecimal_float_leading_minus() {
1202 // expected-error @+1 {{hexadecimal float literal should not have a leading minus}}
1203 "foo"() {value = -0x7fff : f16} : () -> ()
1208 func @hexadecimal_float_literal_overflow() {
1209 // expected-error @+1 {{hexadecimal float constant out of range for type}}
1210 "foo"() {value = 0xffffffff : f16} : () -> ()
1215 func @decimal_float_literal() {
1216 // expected-error @+2 {{unexpected decimal integer literal for a floating point value}}
1217 // expected-note @+1 {{add a trailing dot to make the literal a float}}
1218 "foo"() {value = 42 : f32} : () -> ()
1223 func @float_in_int_tensor() {
1224 // expected-error @+1 {{expected integer elements, but parsed floating-point}}
1225 "foo"() {bar = dense<[42.0, 42]> : tensor<2xi32>} : () -> ()
1230 func @float_in_bool_tensor() {
1231 // expected-error @+1 {{expected integer elements, but parsed floating-point}}
1232 "foo"() {bar = dense<[true, 42.0]> : tensor<2xi1>} : () -> ()
1237 func @decimal_int_in_float_tensor() {
1238 // expected-error @+1 {{expected floating-point elements, but parsed integer}}
1239 "foo"() {bar = dense<[42, 42.0]> : tensor<2xf32>} : () -> ()
1244 func @bool_in_float_tensor() {
1245 // expected-error @+1 {{expected floating-point elements, but parsed integer}}
1246 "foo"() {bar = dense<[42.0, true]> : tensor<2xf32>} : () -> ()
1251 func @hexadecimal_float_leading_minus_in_tensor() {
1252 // expected-error @+1 {{hexadecimal float literal should not have a leading minus}}
1253 "foo"() {bar = dense<-0x7FFFFFFF> : tensor<2xf32>} : () -> ()
1258 // Check that we report an error when a value could be parsed, but does not fit
1259 // into the specified type.
1260 func @hexadecimal_float_too_wide_for_type_in_tensor() {
1261 // expected-error @+1 {{hexadecimal float constant out of range for type}}
1262 "foo"() {bar = dense<0x7FF0000000000000> : tensor<2xf32>} : () -> ()
1267 // Check that we report an error when a value is too wide to be parsed.
1268 func @hexadecimal_float_too_wide_in_tensor() {
1269 // expected-error @+1 {{hexadecimal float constant out of range for type}}
1270 "foo"() {bar = dense<0x7FFFFFF0000000000000> : tensor<2xf32>} : () -> ()
1275 func @integer_too_wide_in_tensor() {
1276 // expected-error @+1 {{integer constant out of range for type}}
1277 "foo"() {bar = dense<0xFFFFFFFFFFFFFF> : tensor<2xi16>} : () -> ()
1282 func @bool_literal_in_non_bool_tensor() {
1283 // expected-error @+1 {{expected i1 type for 'true' or 'false' values}}
1284 "foo"() {bar = dense<true> : tensor<2xi16>} : () -> ()
1289 // expected-error @+1 {{unbalanced ')' character in pretty dialect name}}
1290 func @bad_arrow(%arg : !unreg.ptr<(i32)->)
1294 func @negative_value_in_unsigned_int_attr() {
1295 // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1296 "foo"() {bar = -5 : ui32} : () -> ()
1301 func @negative_value_in_unsigned_vector_attr() {
1302 // expected-error @+1 {{expected unsigned integer elements, but parsed negative value}}
1303 "foo"() {bar = dense<[5, -5]> : vector<2xui32>} : () -> ()
1308 func @large_bound() {
1309 "test.out_of_range_attribute"() {
1310 // expected-error @+1 {{integer constant out of range for attribute}}
1318 func @large_bound() {
1319 "test.out_of_range_attribute"() {
1320 // expected-error @+1 {{integer constant out of range for attribute}}
1328 func @large_bound() {
1329 "test.out_of_range_attribute"() {
1330 // expected-error @+1 {{integer constant out of range for attribute}}
1338 func @large_bound() {
1339 "test.out_of_range_attribute"() {
1340 // expected-error @+1 {{integer constant out of range for attribute}}
1348 func @large_bound() {
1349 "test.out_of_range_attribute"() {
1350 // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1358 func @large_bound() {
1359 "test.out_of_range_attribute"() {
1360 // expected-error @+1 {{integer constant out of range for attribute}}
1368 func @large_bound() {
1369 "test.out_of_range_attribute"() {
1370 // expected-error @+1 {{integer constant out of range for attribute}}
1378 func @large_bound() {
1379 "test.out_of_range_attribute"() {
1380 // expected-error @+1 {{integer constant out of range for attribute}}
1388 func @large_bound() {
1389 "test.out_of_range_attribute"() {
1390 // expected-error @+1 {{integer constant out of range for attribute}}
1391 attr = -32769 : si16
1398 func @large_bound() {
1399 "test.out_of_range_attribute"() {
1400 // expected-error @+1 {{integer constant out of range for attribute}}
1408 func @large_bound() {
1409 "test.out_of_range_attribute"() {
1410 // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1418 func @large_bound() {
1419 "test.out_of_range_attribute"() {
1420 // expected-error @+1 {{integer constant out of range for attribute}}
1428 func @large_bound() {
1429 "test.out_of_range_attribute"() {
1430 // expected-error @+1 {{integer constant out of range for attribute}}
1431 attr = -2147483649 : i32
1438 func @large_bound() {
1439 "test.out_of_range_attribute"() {
1440 // expected-error @+1 {{integer constant out of range for attribute}}
1441 attr = 4294967296 : i32
1448 func @large_bound() {
1449 "test.out_of_range_attribute"() {
1450 // expected-error @+1 {{integer constant out of range for attribute}}
1451 attr = -2147483649 : si32
1458 func @large_bound() {
1459 "test.out_of_range_attribute"() {
1460 // expected-error @+1 {{integer constant out of range for attribute}}
1461 attr = 2147483648 : si32
1468 func @large_bound() {
1469 "test.out_of_range_attribute"() {
1470 // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1478 func @large_bound() {
1479 "test.out_of_range_attribute"() {
1480 // expected-error @+1 {{integer constant out of range for attribute}}
1481 attr = 4294967296 : ui32
1488 func @large_bound() {
1489 "test.out_of_range_attribute"() {
1490 // expected-error @+1 {{integer constant out of range for attribute}}
1491 attr = -9223372036854775809 : i64
1498 func @large_bound() {
1499 "test.out_of_range_attribute"() {
1500 // expected-error @+1 {{integer constant out of range for attribute}}
1501 attr = 18446744073709551616 : i64
1508 func @large_bound() {
1509 "test.out_of_range_attribute"() {
1510 // expected-error @+1 {{integer constant out of range for attribute}}
1511 attr = -9223372036854775809 : si64
1518 func @large_bound() {
1519 "test.out_of_range_attribute"() {
1520 // expected-error @+1 {{integer constant out of range for attribute}}
1521 attr = 9223372036854775808 : si64
1528 func @large_bound() {
1529 "test.out_of_range_attribute"() {
1530 // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}
1538 func @large_bound() {
1539 "test.out_of_range_attribute"() {
1540 // expected-error @+1 {{integer constant out of range for attribute}}
1541 attr = 18446744073709551616 : ui64
1548 func @really_large_bound() {
1549 "test.out_of_range_attribute"() {
1550 // expected-error @+1 {{integer constant out of range for attribute}}
1551 attr = 79228162514264337593543950336 : ui96
1558 func @really_large_bound() {
1559 "test.out_of_range_attribute"() {
1560 // expected-error @+1 {{integer constant out of range for attribute}}
1561 attr = 79228162514264337593543950336 : i96
1568 func @really_large_bound() {
1569 "test.out_of_range_attribute"() {
1570 // expected-error @+1 {{integer constant out of range for attribute}}
1571 attr = 39614081257132168796771975168 : si96
1578 func @duplicate_dictionary_attr_key() {
1579 // expected-error @+1 {{duplicate key 'a' in dictionary attribute}}
1580 "foo.op"() {a, a} : () -> ()
1585 // expected-error @+1 {{attribute 'attr' occurs more than once in the attribute list}}
1586 test.format_symbol_name_attr_op @name { attr = "xx" }
1590 func @forward_reference_type_check() -> (i8) {
1594 // expected-note @+1 {{previously used here with type 'i8'}}
1598 // expected-error @+1 {{definition of SSA value '%1#0' has type 'f32'}}
1599 %1 = "bar"() : () -> (f32)
1605 func @dominance_error_in_unreachable_op() -> i1 {
1606 %c = arith.constant false
1609 "test.ssacfg_region" () ({ // unreachable
1611 // expected-error @+1 {{operand #0 does not dominate this use}}
1612 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1617 %1 = "foo"() : ()->i64 // expected-note {{operand defined here}}
1624 func @invalid_region_dominance_with_dominance_free_regions() {
1626 "foo.use" (%1) : (i32) -> ()
1628 %1 = arith.constant 0 : i32 // This value is used outside of the region.
1629 "foo.yield" () : () -> ()
1631 // expected-error @+1 {{expected operation name in quotes}}
1632 %2 = arith.constant 1 i32 // Syntax error causes region deletion.
1640 func @foo() {} // expected-error {{expected non-empty function body}}