writer/hlsl: Do not emit `(void) call_expr;`
Just emit `call_expr;` instead.
Fixed: tint:1259
Change-Id: I84a2976d82f891e9263f3e11e5774fcb01ea09bd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67381
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/docs/origin-trial-changes.md b/docs/origin-trial-changes.md
index d6400b2..e9aa186 100644
--- a/docs/origin-trial-changes.md
+++ b/docs/origin-trial-changes.md
@@ -21,6 +21,7 @@
### Fixes
* Swizzling of `vec3` types in `storage` and `uniform` buffers has been fixed for Metal 1.x. [tint:1249](https://crbug.com/tint/1249)
+* Calling a function that returns an unused value no longer produces an FXC compilation error. [tint:1259](https://crbug.com/tint/1259)
## Changes for M95
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index 17b8354..dd287de 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -2907,9 +2907,6 @@
}
if (auto* c = stmt->As<ast::CallStatement>()) {
auto out = line();
- if (!TypeOf(c->expr)->Is<sem::Void>()) {
- out << "(void) ";
- }
if (!EmitCall(out, c->expr)) {
return false;
}
diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc
index 0065e5b..92f5c55 100644
--- a/src/writer/hlsl/generator_impl_intrinsic_test.cc
+++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc
@@ -317,7 +317,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_modf(1.0f);
+ tint_modf(1.0f);
return;
}
)");
@@ -343,7 +343,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_modf(float3(0.0f, 0.0f, 0.0f));
+ tint_modf(float3(0.0f, 0.0f, 0.0f));
return;
}
)");
@@ -369,7 +369,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_frexp(1.0f);
+ tint_frexp(1.0f);
return;
}
)");
@@ -395,7 +395,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_frexp(float3(0.0f, 0.0f, 0.0f));
+ tint_frexp(float3(0.0f, 0.0f, 0.0f));
return;
}
)");
@@ -418,7 +418,7 @@
[numthreads(1, 1, 1)]
void test_function() {
float val = 0.0f;
- (void) tint_isNormal(val);
+ tint_isNormal(val);
return;
}
)");
@@ -441,7 +441,7 @@
[numthreads(1, 1, 1)]
void test_function() {
float3 val = float3(0.0f, 0.0f, 0.0f);
- (void) tint_isNormal(val);
+ tint_isNormal(val);
return;
}
)");
@@ -463,7 +463,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_pack4x8snorm(p1);
+ tint_pack4x8snorm(p1);
return;
}
)");
@@ -485,7 +485,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_pack4x8unorm(p1);
+ tint_pack4x8unorm(p1);
return;
}
)");
@@ -507,7 +507,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_pack2x16snorm(p1);
+ tint_pack2x16snorm(p1);
return;
}
)");
@@ -529,7 +529,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_pack2x16unorm(p1);
+ tint_pack2x16unorm(p1);
return;
}
)");
@@ -551,7 +551,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_pack2x16float(p1);
+ tint_pack2x16float(p1);
return;
}
)");
@@ -574,7 +574,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_unpack4x8snorm(p1);
+ tint_unpack4x8snorm(p1);
return;
}
)");
@@ -597,7 +597,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_unpack4x8unorm(p1);
+ tint_unpack4x8unorm(p1);
return;
}
)");
@@ -620,7 +620,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_unpack2x16snorm(p1);
+ tint_unpack2x16snorm(p1);
return;
}
)");
@@ -643,7 +643,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_unpack2x16unorm(p1);
+ tint_unpack2x16unorm(p1);
return;
}
)");
@@ -665,7 +665,7 @@
[numthreads(1, 1, 1)]
void test_function() {
- (void) tint_unpack2x16float(p1);
+ tint_unpack2x16float(p1);
return;
}
)");
diff --git a/test/intrinsics/repeated_use.wgsl.expected.hlsl b/test/intrinsics/repeated_use.wgsl.expected.hlsl
index f0a247f..c89b9fb 100644
--- a/test/intrinsics/repeated_use.wgsl.expected.hlsl
+++ b/test/intrinsics/repeated_use.wgsl.expected.hlsl
@@ -24,17 +24,17 @@
[numthreads(1, 1, 1)]
void main() {
- (void) tint_isNormal(float4(0.0f, 0.0f, 0.0f, 0.0f));
- (void) tint_isNormal(float4((1.0f).xxxx));
- (void) tint_isNormal(float4(1.0f, 2.0f, 3.0f, 4.0f));
- (void) tint_isNormal_1(float3(0.0f, 0.0f, 0.0f));
- (void) tint_isNormal_1(float3((1.0f).xxx));
- (void) tint_isNormal_1(float3(1.0f, 2.0f, 3.0f));
- (void) tint_isNormal_2(float2(0.0f, 0.0f));
- (void) tint_isNormal_2(float2((1.0f).xx));
- (void) tint_isNormal_2(float2(1.0f, 2.0f));
- (void) tint_isNormal_3(1.0f);
- (void) tint_isNormal_3(2.0f);
- (void) tint_isNormal_3(3.0f);
+ tint_isNormal(float4(0.0f, 0.0f, 0.0f, 0.0f));
+ tint_isNormal(float4((1.0f).xxxx));
+ tint_isNormal(float4(1.0f, 2.0f, 3.0f, 4.0f));
+ tint_isNormal_1(float3(0.0f, 0.0f, 0.0f));
+ tint_isNormal_1(float3((1.0f).xxx));
+ tint_isNormal_1(float3(1.0f, 2.0f, 3.0f));
+ tint_isNormal_2(float2(0.0f, 0.0f));
+ tint_isNormal_2(float2((1.0f).xx));
+ tint_isNormal_2(float2(1.0f, 2.0f));
+ tint_isNormal_3(1.0f);
+ tint_isNormal_3(2.0f);
+ tint_isNormal_3(3.0f);
return;
}
diff --git a/test/statements/assign/phony/call.wgsl.expected.hlsl b/test/statements/assign/phony/call.wgsl.expected.hlsl
index 2df8bdf..3d18ac9 100644
--- a/test/statements/assign/phony/call.wgsl.expected.hlsl
+++ b/test/statements/assign/phony/call.wgsl.expected.hlsl
@@ -4,6 +4,6 @@
[numthreads(1, 1, 1)]
void main() {
- (void) f(1, 2, 3);
+ f(1, 2, 3);
return;
}