[type-determiner] Handle pointer arguments.

Currently if the type determiner is determining an identifier it will
wrap it into a pointer if it isn't a constant. This CL updates to make
sure we don't already have a pointer as otherwise we endup with a double
pointer.

Bug: tint:216
Change-Id: I2f8c83bd8680df6c3aef31e1cbb754fdff709b4b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28442
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/type_determiner.cc b/src/type_determiner.cc
index 79ec8dc..479382f 100644
--- a/src/type_determiner.cc
+++ b/src/type_determiner.cc
@@ -719,6 +719,8 @@
     // the pointer around the variable type.
     if (var->is_const()) {
       expr->set_result_type(var->type());
+    } else if (var->type()->IsPointer()) {
+      expr->set_result_type(var->type());
     } else {
       expr->set_result_type(
           ctx_.type_mgr().Get(std::make_unique<ast::type::PointerType>(
diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc
index 52541c2..926fbde 100644
--- a/src/type_determiner_test.cc
+++ b/src/type_determiner_test.cc
@@ -808,6 +808,32 @@
   EXPECT_TRUE(my_var_ptr->result_type()->AsPointer()->type()->IsF32());
 }
 
+TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) {
+  ast::type::F32Type f32;
+  ast::type::PointerType ptr(&f32, ast::StorageClass::kFunction);
+
+  auto my_var = std::make_unique<ast::IdentifierExpression>("my_var");
+  auto* my_var_ptr = my_var.get();
+
+  auto body = std::make_unique<ast::BlockStatement>();
+  body->append(std::make_unique<ast::VariableDeclStatement>(
+      std::make_unique<ast::Variable>("my_var", ast::StorageClass::kNone,
+                                      &ptr)));
+
+  body->append(std::make_unique<ast::AssignmentStatement>(
+      std::move(my_var),
+      std::make_unique<ast::IdentifierExpression>("my_var")));
+
+  ast::Function f("my_func", {}, &f32);
+  f.set_body(std::move(body));
+
+  EXPECT_TRUE(td()->DetermineFunction(&f));
+
+  ASSERT_NE(my_var_ptr->result_type(), nullptr);
+  EXPECT_TRUE(my_var_ptr->result_type()->IsPointer());
+  EXPECT_TRUE(my_var_ptr->result_type()->AsPointer()->type()->IsF32());
+}
+
 TEST_F(TypeDeterminerTest, Expr_Identifier_Function) {
   ast::type::F32Type f32;