Disallow taking the address of a vector component

Update or remove tests that try to do this.

Fixed: tint:491
Change-Id: I1f351a4abf68ae9bc6b100885fb1bcea08b31211
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68242
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2021-11-04 19:55:57 +00:00
parent def9d97609
commit 85170d76bc
18 changed files with 87 additions and 231 deletions

View File

@@ -59,18 +59,18 @@ fn f() {
TEST_F(InlinePointerLetsTest, ComplexChain) {
auto* src = R"(
fn f() {
var m : mat4x4<f32>;
let mp : ptr<function, mat4x4<f32>> = &m;
var a : array<mat4x4<f32>, 4>;
let ap : ptr<function, array<mat4x4<f32>, 4>> = &a;
let mp : ptr<function, mat4x4<f32>> = &(*ap)[3];
let vp : ptr<function, vec4<f32>> = &(*mp)[2];
let fp : ptr<function, f32> = &(*vp)[1];
let f : f32 = *fp;
let v : vec4<f32> = *vp;
}
)";
auto* expect = R"(
fn f() {
var m : mat4x4<f32>;
let f : f32 = *(&((*(&((*(&(m)))[2])))[1]));
var a : array<mat4x4<f32>, 4>;
let v : vec4<f32> = *(&((*(&((*(&(a)))[3])))[2]));
}
)";
@@ -94,15 +94,6 @@ fn arr() {
*p = 4;
}
fn vector() {
var v : vec3<f32>;
var i : i32 = 0;
var j : i32 = 0;
let p : ptr<function, f32> = &v[i + j];
i = 2;
*p = 4.0;
}
fn matrix() {
var m : mat3x3<f32>;
var i : i32 = 0;
@@ -127,22 +118,13 @@ fn arr() {
*(&(a[p_save].i)) = 4;
}
fn vector() {
var v : vec3<f32>;
var i : i32 = 0;
var j : i32 = 0;
let p_save_1 = (i + j);
i = 2;
*(&(v[p_save_1])) = 4.0;
}
fn matrix() {
var m : mat3x3<f32>;
var i : i32 = 0;
var j : i32 = 0;
let p_save_2 = (i + j);
let p_save_1 = (i + j);
i = 2;
*(&(m[p_save_2])) = vec3<f32>(4.0, 5.0, 6.0);
*(&(m[p_save_1])) = vec3<f32>(4.0, 5.0, 6.0);
}
)";