resolver: Reenable VS validation for returning position

Fixed: tint:730
Change-Id: I7d5ebeffe2d522182d07f554a671bebab1cce2e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54420
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/resolver/entry_point_validation_test.cc b/src/resolver/entry_point_validation_test.cc
index 8f90a22..4971107 100644
--- a/src/resolver/entry_point_validation_test.cc
+++ b/src/resolver/entry_point_validation_test.cc
@@ -530,9 +530,7 @@
 12:34 note: while analysing entry point main)");
 }
 
-// TODO(bclayton): Reenable after CTS is updated
-TEST_F(ResolverEntryPointValidationTest,
-       DISABLED_VertexShaderMustReturnPosition) {
+TEST_F(ResolverEntryPointValidationTest, VertexShaderMustReturnPosition) {
   // [[stage(vertex)]]
   // fn main() {}
   Func(Source{{12, 34}}, "main", {}, ty.void_(), {},
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index bec3f4b..467f55d 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -1119,8 +1119,7 @@
         }
       }
     }
-    // TODO(bclayton): Reenable after CTS is updated
-    if (((false)) && !found) {
+    if (!found) {
       diagnostics_.add_error(
           "a vertex shader must include the 'position' builtin in its return "
           "type",
diff --git a/src/transform/single_entry_point_test.cc b/src/transform/single_entry_point_test.cc
index d882620..d8fe14a 100644
--- a/src/transform/single_entry_point_test.cc
+++ b/src/transform/single_entry_point_test.cc
@@ -103,7 +103,8 @@
 TEST_F(SingleEntryPointTest, MultipleEntryPoints) {
   auto* src = R"(
 [[stage(vertex)]]
-fn vert_main() {
+fn vert_main() -> [[builtin(position)]] vec4<f32> {
+  return vec4<f32>();
 }
 
 [[stage(fragment)]]
@@ -145,8 +146,9 @@
 var<private> d : f32;
 
 [[stage(vertex)]]
-fn vert_main() {
+fn vert_main() -> [[builtin(position)]] vec4<f32> {
   a = 0.0;
+  return vec4<f32>();
 }
 
 [[stage(fragment)]]
@@ -194,8 +196,9 @@
 let d : f32 = 1.0;
 
 [[stage(vertex)]]
-fn vert_main() {
+fn vert_main() -> [[builtin(position)]] vec4<f32> {
   let local_a : f32 = a;
+  return vec4<f32>();
 }
 
 [[stage(fragment)]]
diff --git a/test/bug/tint/292.wgsl b/test/bug/tint/292.wgsl
index b1edc34..78f469c 100644
--- a/test/bug/tint/292.wgsl
+++ b/test/bug/tint/292.wgsl
@@ -1,6 +1,6 @@
 [[stage(vertex)]]
-fn main() {
+fn main() -> [[builtin(position)]] vec4<f32> {
   var light : vec3<f32> = vec3<f32>(1.2, 1., 2.);
   var negative_light : vec3<f32> = -light;
-  return;
+  return vec4<f32>();
 }
diff --git a/test/bug/tint/292.wgsl.expected.hlsl b/test/bug/tint/292.wgsl.expected.hlsl
index 55ca3b7..fe6d7b6 100644
--- a/test/bug/tint/292.wgsl.expected.hlsl
+++ b/test/bug/tint/292.wgsl.expected.hlsl
@@ -1,5 +1,10 @@
-void main() {
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+tint_symbol main() {
   float3 light = float3(1.200000048f, 1.0f, 2.0f);
   float3 negative_light = -(light);
-  return;
+  const tint_symbol tint_symbol_1 = {float4(0.0f, 0.0f, 0.0f, 0.0f)};
+  return tint_symbol_1;
 }
diff --git a/test/bug/tint/292.wgsl.expected.msl b/test/bug/tint/292.wgsl.expected.msl
index e69b692..8d10ef8 100644
--- a/test/bug/tint/292.wgsl.expected.msl
+++ b/test/bug/tint/292.wgsl.expected.msl
@@ -1,9 +1,14 @@
 #include <metal_stdlib>
 
 using namespace metal;
-vertex void tint_symbol() {
+struct tint_symbol_1 {
+  float4 value [[position]];
+};
+
+vertex tint_symbol_1 tint_symbol() {
   float3 light = float3(1.200000048f, 1.0f, 2.0f);
   float3 negative_light = -(light);
-  return;
+  tint_symbol_1 const tint_symbol_2 = {.value=float4()};
+  return tint_symbol_2;
 }
 
diff --git a/test/bug/tint/292.wgsl.expected.spvasm b/test/bug/tint/292.wgsl.expected.spvasm
index 66dcae4..fe735fc 100644
--- a/test/bug/tint/292.wgsl.expected.spvasm
+++ b/test/bug/tint/292.wgsl.expected.spvasm
@@ -1,37 +1,53 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 20
+; Bound: 29
 ; Schema: 0
                OpCapability Shader
                OpMemoryModel Logical GLSL450
-               OpEntryPoint Vertex %main "main" %tint_pointsize
+               OpEntryPoint Vertex %main "main" %tint_pointsize %tint_symbol_1
                OpName %tint_pointsize "tint_pointsize"
+               OpName %tint_symbol_1 "tint_symbol_1"
+               OpName %tint_symbol_2 "tint_symbol_2"
+               OpName %tint_symbol "tint_symbol"
                OpName %main "main"
                OpName %light "light"
                OpName %negative_light "negative_light"
                OpDecorate %tint_pointsize BuiltIn PointSize
+               OpDecorate %tint_symbol_1 BuiltIn Position
       %float = OpTypeFloat 32
 %_ptr_Output_float = OpTypePointer Output %float
           %4 = OpConstantNull %float
 %tint_pointsize = OpVariable %_ptr_Output_float Output %4
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %8 = OpConstantNull %v4float
+%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %8
        %void = OpTypeVoid
-          %5 = OpTypeFunction %void
+          %9 = OpTypeFunction %void %v4float
+         %14 = OpTypeFunction %void
     %float_1 = OpConstant %float 1
     %v3float = OpTypeVector %float 3
 %float_1_20000005 = OpConstant %float 1.20000005
     %float_2 = OpConstant %float 2
-         %13 = OpConstantComposite %v3float %float_1_20000005 %float_1 %float_2
+         %21 = OpConstantComposite %v3float %float_1_20000005 %float_1 %float_2
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %16 = OpConstantNull %v3float
-       %main = OpFunction %void None %5
-          %8 = OpLabel
-      %light = OpVariable %_ptr_Function_v3float Function %16
-%negative_light = OpVariable %_ptr_Function_v3float Function %16
+         %24 = OpConstantNull %v3float
+%tint_symbol_2 = OpFunction %void None %9
+%tint_symbol = OpFunctionParameter %v4float
+         %13 = OpLabel
+               OpStore %tint_symbol_1 %tint_symbol
+               OpReturn
+               OpFunctionEnd
+       %main = OpFunction %void None %14
+         %16 = OpLabel
+      %light = OpVariable %_ptr_Function_v3float Function %24
+%negative_light = OpVariable %_ptr_Function_v3float Function %24
                OpStore %tint_pointsize %float_1
-               OpStore %light %13
-         %18 = OpLoad %v3float %light
-         %17 = OpFNegate %v3float %18
-               OpStore %negative_light %17
+               OpStore %light %21
+         %26 = OpLoad %v3float %light
+         %25 = OpFNegate %v3float %26
+               OpStore %negative_light %25
+         %28 = OpFunctionCall %void %tint_symbol_2 %8
                OpReturn
                OpFunctionEnd
diff --git a/test/bug/tint/292.wgsl.expected.wgsl b/test/bug/tint/292.wgsl.expected.wgsl
index 0ad3c99..08967d9 100644
--- a/test/bug/tint/292.wgsl.expected.wgsl
+++ b/test/bug/tint/292.wgsl.expected.wgsl
@@ -1,6 +1,6 @@
 [[stage(vertex)]]
-fn main() {
+fn main() -> [[builtin(position)]] vec4<f32> {
   var light : vec3<f32> = vec3<f32>(1.200000048, 1.0, 2.0);
   var negative_light : vec3<f32> = -(light);
-  return;
+  return vec4<f32>();
 }