@@ -5805,7 +5805,9 @@ static bool handleHLSLTypeAttr(TypeProcessingState &State,
58055805 const AttributedType *pMatrixOrientation = nullptr ;
58065806 const AttributedType *pNorm = nullptr ;
58075807 const AttributedType *pGLC = nullptr ;
5808- hlsl::GetHLSLAttributedTypes (&S, Type, &pMatrixOrientation, &pNorm, &pGLC);
5808+ const AttributedType *pRDC = nullptr ;
5809+ hlsl::GetHLSLAttributedTypes (&S, Type, &pMatrixOrientation, &pNorm, &pGLC,
5810+ &pRDC);
58095811
58105812 if (pMatrixOrientation &&
58115813 (Kind == AttributeList::AT_HLSLColumnMajor ||
@@ -5839,14 +5841,18 @@ static bool handleHLSLTypeAttr(TypeProcessingState &State,
58395841 return true ;
58405842 }
58415843
5842- if (pGLC && (Kind == AttributeList::AT_HLSLGloballyCoherent ||
5843- Kind == AttributeList::AT_HLSLReorderCoherent)) {
5844- AttributedType::Kind CurAttrKind = pGLC->getAttrKind ();
5845- if (Kind == getAttrListKind (CurAttrKind)) {
5846- S.Diag (Attr.getLoc (), diag::warn_duplicate_attribute_exact)
5847- << Attr.getName () << Attr.getRange ();
5848- }
5849- }
5844+ const bool hasGLC = pGLC;
5845+ const bool addsGLC = Kind == AttributeList::AT_HLSLGloballyCoherent;
5846+ const bool hasRDC = pRDC;
5847+ const bool addsRDC = Kind == AttributeList::AT_HLSLReorderCoherent;
5848+
5849+ const bool hasMismatchingAttrs = hasGLC && hasRDC;
5850+ const bool addsMismatchingAttr = (hasGLC && addsRDC) || (hasRDC && addsGLC);
5851+ if ((hasGLC && addsGLC) || (hasRDC && addsRDC))
5852+ S.Diag (Attr.getLoc (), diag::warn_duplicate_attribute_exact)
5853+ << Attr.getName () << Attr.getRange ();
5854+ else if (!hasMismatchingAttrs && addsMismatchingAttr)
5855+ S.Diag (Attr.getLoc (), diag::warn_hlsl_glc_implies_rdc) << Attr.getRange ();
58505856
58515857 AttributedType::Kind TAK;
58525858 switch (Kind) {
0 commit comments