From 7a45cbbf8bab340d212d72c3cfe9f8c5f5837ccf Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Tue, 19 Jul 2022 23:49:25 -0700 Subject: [PATCH] Add semantic clarification to error on missing output semantic (#4562) * test that when output of entry point function is missing semantic, the output is specified in the error message * remove old comment * add alternate error output message among the set of expected errors --- lib/HLSL/HLSignatureLower.cpp | 9 ++++++--- .../hlsl/semantics/legacy/semantic_missing.hlsl | 8 ++++++++ tools/clang/unittests/HLSL/SystemValueTest.cpp | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 tools/clang/test/HLSLFileCheck/hlsl/semantics/legacy/semantic_missing.hlsl diff --git a/lib/HLSL/HLSignatureLower.cpp b/lib/HLSL/HLSignatureLower.cpp index 2ced8a4a8..3dc3d153d 100644 --- a/lib/HLSL/HLSignatureLower.cpp +++ b/lib/HLSL/HLSignatureLower.cpp @@ -270,9 +270,12 @@ void HLSignatureLower::ProcessArgument(Function *func, llvm::StringRef semanticStr = paramAnnotation.GetSemanticString(); if (semanticStr.empty()) { - dxilutil::EmitErrorOnFunction(HLM.GetModule()->getContext(), func, - "Semantic must be defined for all parameters of an entry function or " - "patch constant function"); + + std::string msg = "Semantic must be defined for all "; + msg += (qual == DxilParamInputQual::Out) ? "outputs " : "parameters "; + msg += "of an entry function or patch constant function"; + + dxilutil::EmitErrorOnFunction(HLM.GetModule()->getContext(), func, msg); return; } UpdateSemanticAndInterpMode(semanticStr, interpMode, sigPoint->GetKind(), diff --git a/tools/clang/test/HLSLFileCheck/hlsl/semantics/legacy/semantic_missing.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/semantics/legacy/semantic_missing.hlsl new file mode 100644 index 000000000..8c97381c5 --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/semantics/legacy/semantic_missing.hlsl @@ -0,0 +1,8 @@ +// RUN: %dxc /Tps_6_0 %s | FileCheck %s +// CHECK: error: Semantic must be defined for all outputs of an entry function or patch constant function + +[RootSignature("")] +float main(float a : A, uint b : SV_Coverage) +{ + return a; +} \ No newline at end of file diff --git a/tools/clang/unittests/HLSL/SystemValueTest.cpp b/tools/clang/unittests/HLSL/SystemValueTest.cpp index 805c9c8dd..2aaa788b0 100644 --- a/tools/clang/unittests/HLSL/SystemValueTest.cpp +++ b/tools/clang/unittests/HLSL/SystemValueTest.cpp @@ -535,11 +535,13 @@ TEST_F(SystemValueTest, VerifyMissingSemanticFailure) { // TODO: add tests for mesh/amplification shaders to system-values.hlsl continue; } + std::wstring sigDefValue(L"Def_Arb_NoSem(uint, arb0)"); CComPtr pResult; CompileHLSLTemplate(pResult, sp, sigDefValue); const char *Errors[] = { "error: Semantic must be defined for all parameters of an entry function or patch constant function", + "error: Semantic must be defined for all outputs of an entry function or patch constant function" }; CheckAnyOperationResultMsg(pResult, Errors, _countof(Errors)); }