|
| 1 | +// RUN: mlir-opt %s -split-input-file -verify-diagnostics| FileCheck %s |
| 2 | + |
| 3 | +// CHECK-LABEL: @test_struct_attr_roundtrip |
| 4 | +func.func @test_struct_attr_roundtrip() -> () { |
| 5 | + // CHECK: attr = #test.custom_struct<type_str = "struct", value = 2, opt_value = [3, 3]> |
| 6 | + "test.op"() {attr = #test.custom_struct<type_str = "struct", value = 2, opt_value = [3, 3]>} : () -> () |
| 7 | + // CHECK: attr = #test.custom_struct<type_str = "struct", value = 2, opt_value = [3, 3]> |
| 8 | + "test.op"() {attr = #test.custom_struct<value = 2, type_str = "struct", opt_value = [3, 3]>} : () -> () |
| 9 | + // CHECK: attr = #test.custom_struct<type_str = "struct", value = 2> |
| 10 | + "test.op"() {attr = #test.custom_struct<type_str = "struct", value = 2>} : () -> () |
| 11 | + // CHECK: attr = #test.custom_struct<type_str = "struct", value = 2> |
| 12 | + "test.op"() {attr = #test.custom_struct<value = 2, type_str = "struct">} : () -> () |
| 13 | + return |
| 14 | +} |
| 15 | + |
| 16 | +// ----- |
| 17 | + |
| 18 | +// Verify all keywords must be provided. All missing. |
| 19 | + |
| 20 | +// expected-error @below {{failed parsing `TestCustomStructAttr`}} |
| 21 | +// expected-error @below {{expected one of: `type_str`, `value`, `opt_value`}} |
| 22 | +"test.op"() {attr = #test.custom_struct<"struct", 2>} : () -> () |
| 23 | + |
| 24 | +// ----- |
| 25 | + |
| 26 | +// Verify all keywords must be provided. `type_str` missing. |
| 27 | + |
| 28 | +// expected-error @below {{failed parsing `TestCustomStructAttr`}} |
| 29 | +// expected-error @below {{expected one of: `type_str`, `value`, `opt_value`}} |
| 30 | +"test.op"() {attr = #test.custom_struct<"struct", value = 2, opt_value = [3, 3]>} : () -> () |
| 31 | + |
| 32 | +// ----- |
| 33 | + |
| 34 | +// Verify all keywords must be provided. `value` missing. |
| 35 | + |
| 36 | +// expected-error @below {{failed parsing `TestCustomStructAttr`}} |
| 37 | +// expected-error @below {{expected one of: `type_str`, `value`, `opt_value`}} |
| 38 | +"test.op"() {attr = #test.custom_struct<type_str = "struct", 2>} : () -> () |
| 39 | + |
| 40 | +// ----- |
| 41 | + |
| 42 | +// Verify invalid keyword provided. |
| 43 | + |
| 44 | +// expected-error @below {{failed parsing `TestCustomStructAttr`}} |
| 45 | +// expected-error @below {{expected one of: `type_str`, `value`, `opt_value`}} |
| 46 | +"test.op"() {attr = #test.custom_struct<type_str2 = "struct", value = 2>} : () -> () |
| 47 | + |
| 48 | +// ----- |
| 49 | + |
| 50 | +// Verify duplicated keyword provided. |
| 51 | + |
| 52 | +// expected-error @below {{failed parsing `TestCustomStructAttr`}} |
| 53 | +// expected-error @below {{duplicated `type_str` entry}} |
| 54 | +"test.op"() {attr = #test.custom_struct<type_str = "struct", type_str = "struct2", value = 2>} : () -> () |
| 55 | + |
| 56 | +// ----- |
| 57 | + |
| 58 | +// Verify equals missing. |
| 59 | + |
| 60 | +// expected-error @below {{failed parsing `TestCustomStructAttr`}} |
| 61 | +// expected-error @below {{expected '='}} |
| 62 | +"test.op"() {attr = #test.custom_struct<type_str "struct", value = 2>} : () -> () |
0 commit comments