xref: /llvm-project/mlir/test/Target/Cpp/invalid.mlir (revision e47b507562624bf291ab2515699d39c2669b6131)
1// RUN: mlir-translate -split-input-file -mlir-to-cpp -verify-diagnostics %s
2
3// expected-error@+1 {{'func.func' op with multiple blocks needs variables declared at top}}
4func.func @multiple_blocks() {
5^bb1:
6    cf.br ^bb2
7^bb2:
8    return
9}
10
11// -----
12
13func.func @unsupported_op(%arg0: i1) {
14  // expected-error@+1 {{'cf.assert' op unable to find printer for op}}
15  cf.assert %arg0, "assertion foo"
16  return
17}
18
19// -----
20
21// expected-error@+1 {{cannot emit integer type 'i80'}}
22func.func @unsupported_integer_type(%arg0 : i80) {
23  return
24}
25
26// -----
27
28// expected-error@+1 {{cannot emit float type 'f80'}}
29func.func @unsupported_float_type(%arg0 : f80) {
30  return
31}
32
33// -----
34
35// expected-error@+1 {{cannot emit type 'memref<100xf32>'}}
36func.func @memref_type(%arg0 : memref<100xf32>) {
37  return
38}
39
40// -----
41
42// expected-error@+1 {{cannot emit type 'vector<100xf32>'}}
43func.func @vector_type(%arg0 : vector<100xf32>) {
44  return
45}
46
47// -----
48
49// expected-error@+1 {{cannot emit tensor type with non static shape}}
50func.func @non_static_shape(%arg0 : tensor<?xf32>) {
51  return
52}
53
54// -----
55
56// expected-error@+1 {{cannot emit unranked tensor type}}
57func.func @unranked_tensor(%arg0 : tensor<*xf32>) {
58  return
59}
60
61// -----
62
63// expected-error@+1 {{cannot emit tensor of array type}}
64func.func @tensor_of_array(%arg0 : tensor<4x!emitc.array<4xf32>>) {
65  return
66}
67
68// -----
69
70// expected-error@+1 {{cannot emit pointer to array type}}
71func.func @pointer_to_array(%arg0 : !emitc.ptr<!emitc.array<4xf32>>) {
72  return
73}
74
75// -----
76
77// expected-error@+1 {{cannot emit lvalue type as argument type}}
78func.func @lvalue_as_argument(%arg: !emitc.lvalue<i8>) {
79   return
80}
81
82// -----
83
84// expected-error@+1 {{cannot emit array type as result type}}
85func.func @array_as_result(%arg: !emitc.array<4xi8>) -> (!emitc.array<4xi8>) {
86   return %arg : !emitc.array<4xi8>
87}
88
89// -----
90
91func.func @ptr_to_array() {
92  // expected-error@+1 {{cannot emit pointer to array type '!emitc.ptr<!emitc.array<9xi16>>'}}
93  %v = "emitc.variable"(){value = #emitc.opaque<"NULL">} : () -> !emitc.lvalue<!emitc.ptr<!emitc.array<9xi16>>>
94  return
95}
96