func @access_chain_non_composite() -> () {
%0 = spv.constant 1: i32
- // expected-error @+1 {{cannot extract from non-composite type 'f32' with index 0}}
%1 = spv.Variable : !spv.ptr<f32, Function>
+ // expected-error @+1 {{cannot extract from non-composite type 'f32' with index 0}}
%2 = spv.AccessChain %1[%0] : !spv.ptr<f32, Function>
return
}
// -----
func @access_chain_no_indices(%index0 : i32) -> () {
- // expected-error @+1 {{expected at least one index}}
%0 = spv.Variable : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>
+ // expected-error @+1 {{expected at least one index}}
%1 = spv.AccessChain %0[] : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>
return
}
func @access_chain_invalid_type(%index0 : i32) -> () {
%0 = spv.Variable : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>
- // expected-error @+1 {{expected a pointer to composite type, but provided '!spv.array<4 x !spv.array<4 x f32>>'}}
%1 = spv.Load "Function" %0 ["Volatile"] : !spv.array<4x!spv.array<4xf32>>
+ // expected-error @+1 {{expected a pointer to composite type, but provided '!spv.array<4 x !spv.array<4 x f32>>'}}
%2 = spv.AccessChain %1[%index0] : !spv.array<4x!spv.array<4xf32>>
return
}
// -----
func @access_chain_invalid_index_2(%index0 : i32) -> () {
- // expected-error @+1 {{index must be an integer spv.constant to access element of spv.struct}}
%0 = spv.Variable : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Function>
+ // expected-error @+1 {{index must be an integer spv.constant to access element of spv.struct}}
%1 = spv.AccessChain %0[%index0, %index0] : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Function>
return
}
func @access_chain_invalid_constant_type_1() -> () {
%0 = std.constant 1: i32
- // expected-error @+1 {{index must be an integer spv.constant to access element of spv.struct, but provided std.constant}}
%1 = spv.Variable : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Function>
+ // expected-error @+1 {{index must be an integer spv.constant to access element of spv.struct, but provided std.constant}}
%2 = spv.AccessChain %1[%0, %0] : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Function>
return
}
func @access_chain_out_of_bounds() -> () {
%index0 = "spv.constant"() { value = 12: i32} : () -> i32
- // expected-error @+1 {{'spv.AccessChain' op index 12 out of bounds for '!spv.struct<f32, !spv.array<4 x f32>>'}}
%0 = spv.Variable : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Function>
+ // expected-error @+1 {{'spv.AccessChain' op index 12 out of bounds for '!spv.struct<f32, !spv.array<4 x f32>>'}}
%1 = spv.AccessChain %0[%index0, %index0] : !spv.ptr<!spv.struct<f32, !spv.array<4xf32>>, Function>
return
}
// -----
func @access_chain_invalid_accessing_type(%index0 : i32) -> () {
- // expected-error @+1 {{cannot extract from non-composite type 'f32' with index 0}}
%0 = spv.Variable : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>
+ // expected-error @+1 {{cannot extract from non-composite type 'f32' with index 0}}
%1 = spv.AccessChain %0[%index, %index0, %index0] : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>
return