Skip to content

Commit 6701eed

Browse files
authored
[SPIRV] Handle a cast to void (#7227)
Fixes #7134
1 parent 454bbf4 commit 6701eed

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -3657,14 +3657,16 @@ SpirvInstruction *SpirvEmitter::doCastExpr(const CastExpr *expr,
36573657
emitError("implicit cast kind '%0' unimplemented", expr->getExprLoc())
36583658
<< expr->getCastKindName() << expr->getSourceRange();
36593659
expr->dump();
3660-
return 0;
3660+
return nullptr;
36613661
}
36623662
}
3663+
case CastKind::CK_ToVoid:
3664+
return nullptr;
36633665
default:
36643666
emitError("implicit cast kind '%0' unimplemented", expr->getExprLoc())
36653667
<< expr->getCastKindName() << expr->getSourceRange();
36663668
expr->dump();
3667-
return 0;
3669+
return nullptr;
36683670
}
36693671
}
36703672

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %dxc dxc -T cs_6_6 -E Main -spirv %s -fcgl | FileCheck %s
2+
3+
4+
// Make sure no code is generated for the cast to void.
5+
6+
// CHECK: %src_Main = OpFunction %void None
7+
// CHECK-NEXT: OpLabel
8+
// CHECK-NEXT: %x = OpVariable
9+
// CHECK-NEXT: OpStore %x %false
10+
// CHECK-NEXT: OpReturn
11+
// CHECK-NEXT: OpFunctionEnd
12+
13+
[numthreads(1, 1, 1)]
14+
void Main()
15+
{
16+
bool x = false;
17+
(void)x;
18+
}

0 commit comments

Comments
 (0)