Skip to content

Commit c07e548

Browse files
committed
static_cast<unsigned>(TypeDiagContext)
1 parent 96c6b8c commit c07e548

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

tools/clang/lib/Sema/SemaHLSL.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,9 +5536,8 @@ class HLSLExternalSource : public ExternalSemaSource {
55365536
diag::err_typecheck_decl_incomplete_type);
55375537

55385538
if (ContainsLongVector(argType)) {
5539-
const unsigned ConstantBuffersOrTextureBuffersIdx = 0;
55405539
m_sema->Diag(argSrcLoc, diag::err_hlsl_unsupported_long_vector)
5541-
<< TypeDiagContext::ConstantBuffersOrTextureBuffers;
5540+
<< static_cast<unsigned>(TypeDiagContext::ConstantBuffersOrTextureBuffers);
55425541
return true;
55435542
}
55445543
if (DiagnoseTypeElements(
@@ -5660,10 +5659,9 @@ class HLSLExternalSource : public ExternalSemaSource {
56605659
if (Decl && !Decl->isCompleteDefinition())
56615660
return true;
56625661
if (ContainsLongVector(arg.getAsType())) {
5663-
const unsigned TessellationPatchesIDx = 1;
56645662
m_sema->Diag(argLoc.getLocation(),
56655663
diag::err_hlsl_unsupported_long_vector)
5666-
<< TypeDiagContext::TessellationPatches;
5664+
<< static_cast<unsigned>(TypeDiagContext::TessellationPatches);
56675665
return true;
56685666
}
56695667
if (DiagnoseTypeElements(*m_sema, argLoc.getLocation(), arg.getAsType(),
@@ -5684,7 +5682,7 @@ class HLSLExternalSource : public ExternalSemaSource {
56845682
if (ContainsLongVector(arg.getAsType())) {
56855683
m_sema->Diag(argLoc.getLocation(),
56865684
diag::err_hlsl_unsupported_long_vector)
5687-
<< TypeDiagContext::GeometryStreams;
5685+
<< static_cast<unsigned>(TypeDiagContext::GeometryStreams);
56885686
return true;
56895687
}
56905688
if (DiagnoseTypeElements(*m_sema, argLoc.getLocation(), arg.getAsType(),
@@ -10808,8 +10806,7 @@ bool DiagnoseIntersectionAttributes(Sema &S, SourceLocation Loc, QualType Ty) {
1080810806
}
1080910807

1081010808
if (ContainsLongVector(Ty)) {
10811-
const unsigned AttributesIdx = 11;
10812-
S.Diag(Loc, diag::err_hlsl_unsupported_long_vector) << AttributesIdx;
10809+
S.Diag(Loc, diag::err_hlsl_unsupported_long_vector) << static_cast<unsigned>(TypeDiagContext::Attributes);
1081310810
return false;
1081410811
}
1081510812
return true;
@@ -15405,7 +15402,7 @@ bool Sema::DiagnoseHLSLDecl(Declarator &D, DeclContext *DC, Expr *BitWidth,
1540515402
if (isGlobal && !isStatic && !isGroupShared && !IS_BASIC_OBJECT(basicKind)) {
1540615403
if (ContainsLongVector(qt)) {
1540715404
Diag(D.getLocStart(), diag::err_hlsl_unsupported_long_vector)
15408-
<< TypeDiagContext::CbuffersOrTbuffers;
15405+
<< static_cast<unsigned>(TypeDiagContext::CBuffersOrTBuffers);
1540915406

1541015407
result = false;
1541115408
}
@@ -16314,9 +16311,8 @@ static bool isRelatedDeclMarkedNointerpolation(Expr *E) {
1631416311
// Verify that user-defined intrinsic struct args contain no long vectors
1631516312
static bool CheckUDTIntrinsicArg(Sema *S, Expr *Arg) {
1631616313
if (ContainsLongVector(Arg->getType())) {
16317-
const unsigned UserDefinedStructParameterIdx = 5;
1631816314
S->Diag(Arg->getExprLoc(), diag::err_hlsl_unsupported_long_vector)
16319-
<< UserDefinedStructParameterIdx;
16315+
<< static_cast<unsigned>(TypeDiagContext::UserDefinedStructParameter);
1632016316
return true;
1632116317
}
1632216318
return DiagnoseTypeElements(*S, Arg->getExprLoc(), Arg->getType(),
@@ -17058,17 +17054,16 @@ void DiagnoseEntry(Sema &S, FunctionDecl *FD) {
1705817054
// See issue #7186.
1705917055
for (const auto *param : FD->params()) {
1706017056
if (ContainsLongVector(param->getType())) {
17061-
const unsigned EntryFunctionParametersIdx = 6;
1706217057
S.Diag(param->getLocation(), diag::err_hlsl_unsupported_long_vector)
17063-
<< EntryFunctionParametersIdx;
17058+
<< static_cast<unsigned>(TypeDiagContext::EntryFunctionParameters);
1706417059
}
1706517060
hlsl::DiagnoseTypeElements(S, param->getLocation(), param->getType(),
1706617061
TypeDiagContext::EntryFunctionParameters);
1706717062
}
1706817063

1706917064
if (ContainsLongVector(FD->getReturnType())) {
1707017065
S.Diag(FD->getLocation(), diag::err_hlsl_unsupported_long_vector)
17071-
<< TypeDiagContext::EntryFunctionReturnType;
17066+
<< static_cast<unsigned>(TypeDiagContext::EntryFunctionReturnType);
1707217067
}
1707317068
DiagnoseTypeElements(S, FD->getLocation(), FD->getReturnType(),
1707417069
TypeDiagContext::EntryFunctionReturnType);

tools/clang/lib/Sema/SemaHLSLDiagnoseTU.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,20 +710,18 @@ void hlsl::DiagnoseTranslationUnit(clang::Sema *self) {
710710
}
711711
}
712712
for (const auto *param : pPatchFnDecl->params()) {
713-
const unsigned PatchConstantFunctionParametersIdx = 8;
714713
if (ContainsLongVector(param->getType()))
715714
self->Diag(param->getLocation(),
716715
diag::err_hlsl_unsupported_long_vector)
717-
<< TypeDiagContext::PatchConstantFunctionParameters;
716+
<< static_cast<unsigned>(TypeDiagContext::PatchConstantFunctionParameters);
718717
DiagnoseTypeElements(*self, param->getLocation(), param->getType(),
719718
TypeDiagContext::PatchConstantFunctionParameters);
720719
}
721720

722721
if (ContainsLongVector(pPatchFnDecl->getReturnType())) {
723-
const unsigned PatchConstantFunctionReturnIdx = 9;
724722
self->Diag(pPatchFnDecl->getLocation(),
725723
diag::err_hlsl_unsupported_long_vector)
726-
<< PatchConstantFunctionReturnIdx;
724+
<< static_cast<unsigned>(TypeDiagContext::PatchConstantFunctionReturnType);
727725
}
728726
DiagnoseTypeElements(*self, pPatchFnDecl->getLocation(),
729727
pPatchFnDecl->getReturnType(),

0 commit comments

Comments
 (0)