1 // RUN: mlir-opt -allow-unregistered-dialect -split-input-file %s -verify-diagnostics
3 func.func @unsupported_attribute() {
4 // expected-error @+1 {{invalid kind of attribute specified}}
5 %0 = constant "" : index
11 func.func private @return_i32_f32() -> (i32, f32)
14 // expected-error @+3 {{op result type mismatch at index 0}}
15 // expected-note @+2 {{op result types: 'f32', 'i32'}}
16 // expected-note @+1 {{function result types: 'i32', 'f32'}}
17 %0:2 = call @return_i32_f32() : () -> (f32, i32)
23 func.func @resulterror() -> i32 {
25 return // expected-error {{'func.return' op has 0 operands, but enclosing function (@resulterror) returns 1}}
30 func.func @return_type_mismatch() -> i32 {
31 %0 = "foo"() : ()->f32
32 return %0 : f32 // expected-error {{type of return operand 0 ('f32') doesn't match function result type ('i32') in function @return_type_mismatch}}
37 func.func @return_inside_loop() {
38 affine.for %i = 1 to 100 {
39 // expected-error@+1 {{'func.return' op expects parent op 'func.func'}}
47 // expected-error@+1 {{expected non-function type}}
48 func.func @func_variadic(...)
54 %x = constant @foo : (i32) -> () // expected-error {{reference to function with mismatched type}}
60 func.func @undefined_function() {
62 %x = constant @qux : (i32) -> () // expected-error {{reference to undefined function 'qux'}}
68 #map1 = affine_map<(i)[j] -> (i+j)>
70 func.func @bound_symbol_mismatch(%N : index) {
71 affine.for %i = #map1(%N) to 100 {
72 // expected-error@-1 {{symbol operand count and affine map symbol count must match}}
79 #map1 = affine_map<(i)[j] -> (i+j)>
81 func.func @bound_dim_mismatch(%N : index) {
82 affine.for %i = #map1(%N, %N)[%N] to 100 {
83 // expected-error@-1 {{dim operand count and affine map dim count must match}}
90 func.func @large_bound() {
91 affine.for %i = 1 to 9223372036854775810 {
92 // expected-error@-1 {{integer constant out of range for attribute}}
99 func.func @max_in_upper_bound(%N : index) {
100 affine.for %i = 1 to max affine_map<(i)->(N, 100)> { //expected-error {{expected attribute value}}
107 func.func @step_typo() {
108 affine.for %i = 1 to 100 step -- 1 { //expected-error {{expected constant integer}}
115 func.func @invalid_bound_map(%N : i32) {
116 affine.for %i = 1 to affine_map<(i)->(j)>(%N) { //expected-error {{use of undeclared identifier}}
123 // expected-error @+1 {{expected '(' in integer set constraint list}}
124 #set0 = affine_set<(i)[N, M] : )i >= 0)>
127 #set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
129 func.func @invalid_if_operands1(%N : index) {
130 affine.for %i = 1 to 10 {
131 affine.if #set0(%i) {
132 // expected-error@-1 {{symbol operand count and integer set symbol count must match}}
135 #set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
137 func.func @invalid_if_operands2(%N : index) {
138 affine.for %i = 1 to 10 {
139 affine.if #set0()[%N] {
140 // expected-error@-1 {{dim operand count and integer set dim count must match}}
143 #set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
145 func.func @invalid_if_operands3(%N : index) {
146 affine.for %i = 1 to 10 {
147 affine.if #set0(%i)[%i] {
148 // expected-error@-1 {{operand cannot be used as a symbol}}
156 func.func @redundant_signature(%a : i32) -> () {
157 ^bb0(%b : i32): // expected-error {{invalid block name in region with named arguments}}
163 func.func @mixed_named_arguments(%a : i32,
165 // expected-error @-1 {{expected SSA identifier}}
171 func.func @mixed_named_arguments(f32,
172 %a : i32) -> () { // expected-error {{expected type instead of SSA identifier}}
178 // expected-error @+1 {{@ identifier expected to start with letter or '_'}}
179 func.func @$invalid_function_name()
183 // expected-error @+1 {{arguments may only have dialect attributes}}
184 func.func private @invalid_func_arg_attr(i1 {non_dialect_attr = 10})
188 // expected-error @+1 {{results may only have dialect attributes}}
189 func.func private @invalid_func_result_attr() -> (i1 {non_dialect_attr = 10})
193 func.func @foo() {} // expected-error {{expected non-empty function body}}