Skip to content

Commit e7f8c5a

Browse files
committed
Assert TypeDiagContext enum value compatible with unsupported_long_vector
1 parent 9db0556 commit e7f8c5a

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

tools/clang/include/clang/Sema/SemaHLSL.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ bool DiagnoseNodeStructArgument(clang::Sema *self,
6161

6262
// Keep this in sync with err_hlsl_unsupported_object in DiagnosticSemaKinds.td
6363
enum class TypeDiagContext {
64+
// Supported indices for both `err_hlsl_unsupported_object_context` and
65+
// `err_hlsl_unsupported_long_vector`
6466
ConstantBuffersOrTextureBuffers = 0,
6567
TessellationPatches = 1,
6668
GeometryStreams = 2,
@@ -74,6 +76,8 @@ enum class TypeDiagContext {
7476
PayloadParameters = 10,
7577
Attributes = 11,
7678
TypeParameter = 12,
79+
LongVecDiagMaxSelectIndex = TypeParameter,
80+
// Below only supported for `err_hlsl_diag_unsupported_object_context`
7781
StructuredBuffers = 13,
7882
GlobalVariables = 14,
7983
GroupShared = 15,

tools/clang/lib/Sema/SemaHLSL.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12195,6 +12195,9 @@ DiagnoseElementTypes(Sema &S, SourceLocation Loc, QualType Ty, bool &Empty,
1219512195
// into this function. Could fold all context-dependent long vector checks
1219612196
// into this function.
1219712197
if (CheckLongVec && GetHLSLVecSize(Ty) > DXIL::kDefaultMaxVectorLength) {
12198+
DXASSERT_NOMSG(
12199+
DiagContextIdx <=
12200+
static_cast<unsigned>(TypeDiagContext::LongVecDiagMaxSelectIndex));
1219812201
S.Diag(Loc, diag::err_hlsl_unsupported_long_vector) << DiagContextIdx;
1219912202
Empty = false;
1220012203
return false;

0 commit comments

Comments
 (0)