@@ -13716,18 +13716,35 @@ void Sema::DiagnoseCoherenceMismatch(const Expr *SrcExpr, QualType TargetType,
1371613716 // 'globallycoherent'
1371713717 bool SrcRD = hlsl::HasHLSLReorderCoherent(SrcTy);
1371813718 bool DstRD = hlsl::HasHLSLReorderCoherent(DstTy);
13719- bool DemoteToRD = SrcGL && DstRD;
13720- bool PromoteToGL = SrcRD && DstGL;
13721- if (DemoteToRD || PromoteToGL)
13722- Diag(Loc, diag::warn_hlsl_impcast_rdc_glc_mismatch)
13723- << SrcExpr->getType() << TargetType
13724- << /*demotes|promotes*/ PromoteToGL;
13725- else if (SrcGL != DstGL)
13726- Diag(Loc, diag::warn_hlsl_impcast_glc_mismatch)
13727- << SrcExpr->getType() << TargetType << /*loses|adds*/ DstGL;
13728- else if (SrcRD != DstRD)
13729- Diag(Loc, diag::warn_hlsl_impcast_rdc_mismatch)
13730- << SrcExpr->getType() << TargetType << /*loses|adds*/ DstRD;
13719+
13720+ enum {
13721+ NoMismatch = -1,
13722+ DemoteToRD = 0,
13723+ PromoteToGL = 1,
13724+ LosesRD = 2,
13725+ LosesGL = 3,
13726+ AddsRD = 4,
13727+ AddsGL = 5
13728+ } MismatchType = NoMismatch;
13729+
13730+ if (SrcGL && DstRD)
13731+ MismatchType = DemoteToRD;
13732+ else if (SrcRD && DstGL)
13733+ MismatchType = PromoteToGL;
13734+ else if (SrcRD && !DstRD)
13735+ MismatchType = LosesRD;
13736+ else if (SrcGL && !DstGL)
13737+ MismatchType = LosesGL;
13738+ else if (!SrcRD && DstRD)
13739+ MismatchType = AddsRD;
13740+ else if (!SrcGL && DstGL)
13741+ MismatchType = AddsGL;
13742+
13743+ if (MismatchType == NoMismatch)
13744+ return;
13745+
13746+ Diag(Loc, diag::warn_hlsl_impcast_coherence_mismatch)
13747+ << SrcExpr->getType() << TargetType << MismatchType;
1373113748 }
1373213749}
1373313750
0 commit comments