diff --git a/tools/clang/lib/SPIRV/SpirvEmitter.cpp b/tools/clang/lib/SPIRV/SpirvEmitter.cpp index 7337a33b01..5411b3555e 100644 --- a/tools/clang/lib/SPIRV/SpirvEmitter.cpp +++ b/tools/clang/lib/SPIRV/SpirvEmitter.cpp @@ -2021,6 +2021,10 @@ void SpirvEmitter::doVarDecl(const VarDecl *decl) { // variables) belongs to the Function storage class. if (isExternalVar(decl)) { var = declIdMapper.createExternVar(decl); + if (decl->hasInit()) { + emitWarning("Initializer of external global will be ignored", + decl->getLocation()); + } } else { // We already know the variable is not externally visible here. If it does // not have local storage, it should be file scope variable. diff --git a/tools/clang/test/CodeGenSPIRV/groupshared.init.warning.hlsl b/tools/clang/test/CodeGenSPIRV/groupshared.init.warning.hlsl new file mode 100644 index 0000000000..c49534948b --- /dev/null +++ b/tools/clang/test/CodeGenSPIRV/groupshared.init.warning.hlsl @@ -0,0 +1,19 @@ +// RUN: %dxc -T cs_6_0 -E main -spirv %s 2>&1 | FileCheck %s + +groupshared uint testing = 0; + +[numthreads(64, 1, 1)] +void main(uint local_thread_id_flat : SV_GroupIndex) { + + InterlockedAdd(testing, 1); + GroupMemoryBarrierWithGroupSync(); + + if (local_thread_id_flat == 0) { + if (testing > 64) { + printf("testing is %u wtf", testing); + } + } +} + +// CHECK: warning: Initializer of external global will be ignored +// CHECK-NEXT: groupshared uint testing = 0; \ No newline at end of file