type determine accessor on aliased array
Change-Id: I8084bf6c30649acb2d6d7639fa6bf78cdd0a4a6a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23581 Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
parent
32a4f957b4
commit
9c88ea5988
|
@ -369,7 +369,7 @@ bool TypeDeterminer::DetermineArrayAccessor(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* res = expr->array()->result_type();
|
auto* res = expr->array()->result_type();
|
||||||
auto* parent_type = res->UnwrapPtrIfNeeded();
|
auto* parent_type = res->UnwrapAliasPtrAlias();
|
||||||
ast::type::Type* ret = nullptr;
|
ast::type::Type* ret = nullptr;
|
||||||
if (parent_type->IsArray()) {
|
if (parent_type->IsArray()) {
|
||||||
ret = parent_type->AsArray()->type();
|
ret = parent_type->AsArray()->type();
|
||||||
|
|
|
@ -400,6 +400,31 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) {
|
||||||
EXPECT_TRUE(ptr->type()->IsF32());
|
EXPECT_TRUE(ptr->type()->IsF32());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) {
|
||||||
|
ast::type::I32Type i32;
|
||||||
|
ast::type::F32Type f32;
|
||||||
|
ast::type::ArrayType ary(&f32, 3);
|
||||||
|
ast::type::AliasType aary("myarrty", &ary);
|
||||||
|
|
||||||
|
auto idx = std::make_unique<ast::ScalarConstructorExpression>(
|
||||||
|
std::make_unique<ast::SintLiteral>(&i32, 2));
|
||||||
|
auto var = std::make_unique<ast::Variable>(
|
||||||
|
"my_var", ast::StorageClass::kFunction, &aary);
|
||||||
|
mod()->AddGlobalVariable(std::move(var));
|
||||||
|
|
||||||
|
// Register the global
|
||||||
|
EXPECT_TRUE(td()->Determine());
|
||||||
|
|
||||||
|
ast::ArrayAccessorExpression acc(
|
||||||
|
std::make_unique<ast::IdentifierExpression>("my_var"), std::move(idx));
|
||||||
|
EXPECT_TRUE(td()->DetermineResultType(&acc));
|
||||||
|
ASSERT_NE(acc.result_type(), nullptr);
|
||||||
|
ASSERT_TRUE(acc.result_type()->IsPointer());
|
||||||
|
|
||||||
|
auto* ptr = acc.result_type()->AsPointer();
|
||||||
|
EXPECT_TRUE(ptr->type()->IsF32());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) {
|
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) {
|
||||||
ast::type::I32Type i32;
|
ast::type::I32Type i32;
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
|
Loading…
Reference in New Issue