Type determine the call statement.

This CL adds type determination for the call statement.

Bug: tint:45
Change-Id: I2460fe6c6103bdf7e5d0367cded1d78ca5d671d6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25321
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/type_determiner.cc b/src/type_determiner.cc
index 6b1d139..5d2c983 100644
--- a/src/type_determiner.cc
+++ b/src/type_determiner.cc
@@ -24,6 +24,7 @@
 #include "src/ast/binary_expression.h"
 #include "src/ast/break_statement.h"
 #include "src/ast/call_expression.h"
+#include "src/ast/call_statement.h"
 #include "src/ast/case_statement.h"
 #include "src/ast/cast_expression.h"
 #include "src/ast/continue_statement.h"
@@ -284,6 +285,9 @@
   if (stmt->IsBreak()) {
     return true;
   }
+  if (stmt->IsCall()) {
+    return DetermineResultType(stmt->AsCall()->expr());
+  }
   if (stmt->IsCase()) {
     auto* c = stmt->AsCase();
     return DetermineStatements(c->body());
diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc
index 983ac36..b46cfb7 100644
--- a/src/type_determiner_test.cc
+++ b/src/type_determiner_test.cc
@@ -26,6 +26,7 @@
 #include "src/ast/binary_expression.h"
 #include "src/ast/break_statement.h"
 #include "src/ast/call_expression.h"
+#include "src/ast/call_statement.h"
 #include "src/ast/case_statement.h"
 #include "src/ast/cast_expression.h"
 #include "src/ast/continue_statement.h"
@@ -338,6 +339,29 @@
   EXPECT_TRUE(rhs_ptr->result_type()->IsF32());
 }
 
+TEST_F(TypeDeterminerTest, Stmt_Call) {
+  ast::type::F32Type f32;
+
+  ast::VariableList params;
+  auto func =
+      std::make_unique<ast::Function>("my_func", std::move(params), &f32);
+  mod()->AddFunction(std::move(func));
+
+  // Register the function
+  EXPECT_TRUE(td()->Determine());
+
+  ast::ExpressionList call_params;
+  auto expr = std::make_unique<ast::CallExpression>(
+      std::make_unique<ast::IdentifierExpression>("my_func"),
+      std::move(call_params));
+  auto* expr_ptr = expr.get();
+
+  ast::CallStatement call(std::move(expr));
+  EXPECT_TRUE(td()->DetermineResultType(&call));
+  ASSERT_NE(expr_ptr->result_type(), nullptr);
+  EXPECT_TRUE(expr_ptr->result_type()->IsF32());
+}
+
 TEST_F(TypeDeterminerTest, Stmt_VariableDecl) {
   ast::type::I32Type i32;
   auto var =