diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index 5159a5c285..4df32f9a65 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -3817,29 +3817,41 @@ class HLSLExternalSource : public ExternalSemaSource { recordDecl = m_ThreadNodeOutputRecordsTemplateDecl->getTemplatedDecl(); } #ifdef ENABLE_SPIRV_CODEGEN - else if (kind == AR_OBJECT_VK_SPIRV_TYPE && m_vkNSDecl) { + else if (kind == AR_OBJECT_VK_SPIRV_TYPE) { + if (!m_vkNSDecl) + continue; recordDecl = DeclareInlineSpirvType(*m_context, m_vkNSDecl, typeName, false); recordDecl->setImplicit(true); - } else if (kind == AR_OBJECT_VK_SPIRV_OPAQUE_TYPE && m_vkNSDecl) { + } else if (kind == AR_OBJECT_VK_SPIRV_OPAQUE_TYPE) { + if (!m_vkNSDecl) + continue; recordDecl = DeclareInlineSpirvType(*m_context, m_vkNSDecl, typeName, true); recordDecl->setImplicit(true); - } else if (kind == AR_OBJECT_VK_INTEGRAL_CONSTANT && m_vkNSDecl) { + } else if (kind == AR_OBJECT_VK_INTEGRAL_CONSTANT) { + if (!m_vkNSDecl) + continue; recordDecl = DeclareVkIntegralConstant(*m_context, m_vkNSDecl, typeName, &m_vkIntegralConstantTemplateDecl); recordDecl->setImplicit(true); - } else if (kind == AR_OBJECT_VK_LITERAL && m_vkNSDecl) { + } else if (kind == AR_OBJECT_VK_LITERAL) { + if (!m_vkNSDecl) + continue; recordDecl = DeclareTemplateTypeWithHandleInDeclContext( *m_context, m_vkNSDecl, typeName, 1, nullptr); recordDecl->setImplicit(true); m_vkLiteralTemplateDecl = recordDecl->getDescribedClassTemplate(); - } else if (kind == AR_OBJECT_VK_SPV_INTRINSIC_TYPE && m_vkNSDecl) { + } else if (kind == AR_OBJECT_VK_SPV_INTRINSIC_TYPE) { + if (!m_vkNSDecl) + continue; recordDecl = DeclareUIntTemplatedTypeWithHandleInDeclContext( *m_context, m_vkNSDecl, typeName, "id"); recordDecl->setImplicit(true); - } else if (kind == AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID && m_vkNSDecl) { + } else if (kind == AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID) { + if (!m_vkNSDecl) + continue; recordDecl = DeclareTemplateTypeWithHandleInDeclContext( *m_context, m_vkNSDecl, typeName, 1, nullptr); recordDecl->setImplicit(true); @@ -4505,8 +4517,6 @@ class HLSLExternalSource : public ExternalSemaSource { int startDepth = (templateArgCount == 0) ? 0 : 1; CXXRecordDecl *recordDecl = m_objectTypeDecls[i]; if (recordDecl == nullptr) { - DXASSERT(kind == AR_OBJECT_WAVE, - "else objects other than reserved not initialized"); continue; } diff --git a/tools/clang/test/SemaHLSL/vk.types.in.dxil.hlsl b/tools/clang/test/SemaHLSL/vk.types.in.dxil.hlsl new file mode 100644 index 0000000000..41d9bd650a --- /dev/null +++ b/tools/clang/test/SemaHLSL/vk.types.in.dxil.hlsl @@ -0,0 +1,12 @@ +// RUN: %dxc -T ps_6_0 -E PSMain -fcgl %s -verify + +static const integral_constant MyVar; // expected-error{{unknown type name 'integral_constant'}} +static const SpirvType MyVar; // expected-error{{unknown type name 'SpirvType'}} +static const SpirvOpaqueType MyVar; // expected-error{{unknown type name 'SpirvOpaqueType'}} +static const Literal MyVar; // expected-error{{unknown type name 'Literal'}} + +float4 PSMain() : SV_TARGET +{ + return float4(1.0, 1.0, 1.0, 1.0); +} +