summaryrefslogtreecommitdiff
path: root/mlir/test/IR/enum-attr-invalid.mlir
blob: 2f240a56c987489e76f88cdfe7c18ff1fb3f0b12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// RUN: mlir-opt -verify-diagnostics -split-input-file %s

func.func @test_invalid_enum_case() -> () {
  // expected-error@+2 {{expected test::TestEnum to be one of: first, second, third}}
  // expected-error@+1 {{failed to parse TestEnumAttr}}
  test.op_with_enum #test<enum fourth>
}

// -----

func.func @test_invalid_enum_case() -> () {
  // expected-error@+1 {{expected test::TestEnum to be one of: first, second, third}}
  test.op_with_enum fourth
  // expected-error@+1 {{failed to parse TestEnumAttr}}
}

// -----

func.func @test_invalid_attr() -> () {
  // expected-error@+1 {{op attribute 'value' failed to satisfy constraint: a test enum}}
  "test.op_with_enum"() {value = 1 : index} : () -> ()
}

// -----

func.func @test_parse_invalid_attr() -> () {
  // expected-error@+2 {{expected valid keyword}}
  // expected-error@+1 {{failed to parse TestEnumAttr parameter 'value'}}
  test.op_with_enum 1 : index
}

// -----

func.func @test_non_keyword_prop_enum() -> () {
  // expected-error@+2 {{expected keyword for a test enum}}
  // expected-error@+1 {{invalid value for property value, expected a test enum}}
  test.op_with_enum_prop 0
  return
}

// -----

func.func @test_wrong_keyword_prop_enum() -> () {
  // expected-error@+2 {{expected one of [first, second, third] for a test enum, got: fourth}}
  // expected-error@+1 {{invalid value for property value, expected a test enum}}
  test.op_with_enum_prop fourth
}

// -----

func.func @test_bad_integer() -> () {
  // expected-error@+1 {{op property 'value' failed to satisfy constraint: a test enum}}
  "test.op_with_enum_prop"() <{value = 4 : i32}> {} : () -> ()
}

// -----

func.func @test_bit_enum_prop_not_keyword() -> () {
  // expected-error@+2 {{expected keyword for a test bit enum}}
  // expected-error@+1 {{invalid value for property value1, expected a test bit enum}}
  test.op_with_bit_enum_prop 0
  return
}

// -----

func.func @test_bit_enum_prop_wrong_keyword() -> () {
  // expected-error@+2 {{expected one of [read, write, execute] for a test bit enum, got: chroot}}
  // expected-error@+1 {{invalid value for property value1, expected a test bit enum}}
  test.op_with_bit_enum_prop read, chroot : ()
  return
}

// -----

func.func @test_bit_enum_prop_bad_value() -> () {
  // expected-error@+1 {{op property 'value2' failed to satisfy constraint: a test bit enum}}
  "test.op_with_bit_enum_prop"() <{value1 = 7 : i32, value2 = 8 : i32}> {} : () -> ()
  return
}

// -----

func.func @test_bit_enum_prop_named_wrong_keyword() -> () {
  // expected-error@+2 {{expected 'bit_enum'}}
  // expected-error@+1 {{invalid value for property value1, expected a test bit enum}}
  test.op_with_bit_enum_prop_named foo<read, execute>
  return
}

// -----

func.func @test_bit_enum_prop_named_not_open() -> () {
  // expected-error@+2 {{expected '<'}}
  // expected-error@+1 {{invalid value for property value1, expected a test bit enum}}
  test.op_with_bit_enum_prop_named bit_enum read, execute>
}

// -----

func.func @test_bit_enum_prop_named_not_closed() -> () {
  // expected-error@+2 {{expected '>'}}
  // expected-error@+1 {{invalid value for property value1, expected a test bit enum}}
  test.op_with_bit_enum_prop_named bit_enum<read, execute +
}