Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tools/clang/lib/SPIRV/SpirvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3657,14 +3657,16 @@ SpirvInstruction *SpirvEmitter::doCastExpr(const CastExpr *expr,
emitError("implicit cast kind '%0' unimplemented", expr->getExprLoc())
<< expr->getCastKindName() << expr->getSourceRange();
expr->dump();
return 0;
return nullptr;
}
}
case CastKind::CK_ToVoid:
return nullptr;
default:
emitError("implicit cast kind '%0' unimplemented", expr->getExprLoc())
<< expr->getCastKindName() << expr->getSourceRange();
expr->dump();
return 0;
return nullptr;
}
}

Expand Down
18 changes: 18 additions & 0 deletions tools/clang/test/CodeGenSPIRV/cast.to.void.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %dxc dxc -T cs_6_6 -E Main -spirv %s -fcgl | FileCheck %s


// Make sure no code is generated for the cast to void.

// CHECK: %src_Main = OpFunction %void None
// CHECK-NEXT: OpLabel
// CHECK-NEXT: %x = OpVariable
// CHECK-NEXT: OpStore %x %false
// CHECK-NEXT: OpReturn
// CHECK-NEXT: OpFunctionEnd

[numthreads(1, 1, 1)]
void Main()
{
bool x = false;
(void)x;
}