|
@@ -10,6 +10,7 @@
|
|
|
// //
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
+#include "clang/AST/DeclBase.h"
|
|
|
#include "clang/Basic/Diagnostic.h"
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
@@ -12131,6 +12132,26 @@ bool ValidateAttributeTargetIsFunction(Sema& S, Decl* D, const AttributeList &A)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+void Sema::DiagnoseHLSLDeclAttr(const Decl *D, const Attr *A) {
|
|
|
+ HLSLExternalSource *ExtSource = HLSLExternalSource::FromSema(this);
|
|
|
+ if (const HLSLGloballyCoherentAttr *HLSLGCAttr =
|
|
|
+ dyn_cast<HLSLGloballyCoherentAttr>(A)) {
|
|
|
+ const ValueDecl *TD = cast<ValueDecl>(D);
|
|
|
+ if (!TD->getType()->isDependentType()) {
|
|
|
+ QualType DeclType = TD->getType();
|
|
|
+ while (DeclType->isArrayType())
|
|
|
+ DeclType = QualType(DeclType->getArrayElementTypeNoTypeQual(), 0);
|
|
|
+ if (ExtSource->GetTypeObjectKind(DeclType) != AR_TOBJ_OBJECT ||
|
|
|
+ hlsl::GetResourceClassForType(getASTContext(), DeclType) !=
|
|
|
+ hlsl::DXIL::ResourceClass::UAV) {
|
|
|
+ Diag(A->getLocation(), diag::err_hlsl_varmodifierna)
|
|
|
+ << A << "non-UAV type";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void hlsl::HandleDeclAttributeForHLSL(Sema &S, Decl *D, const AttributeList &A, bool& Handled)
|
|
|
{
|
|
|
DXASSERT_NOMSG(D != nullptr);
|
|
@@ -12296,6 +12317,7 @@ void hlsl::HandleDeclAttributeForHLSL(Sema &S, Decl *D, const AttributeList &A,
|
|
|
|
|
|
if (declAttr != nullptr)
|
|
|
{
|
|
|
+ S.DiagnoseHLSLDeclAttr(D, declAttr);
|
|
|
DXASSERT_NOMSG(Handled);
|
|
|
D->addAttr(declAttr);
|
|
|
return;
|
|
@@ -13127,12 +13149,7 @@ bool Sema::DiagnoseHLSLDecl(Declarator &D, DeclContext *DC, Expr *BitWidth,
|
|
|
result = false;
|
|
|
}
|
|
|
break;
|
|
|
- case AttributeList::AT_HLSLGloballyCoherent:
|
|
|
- if (!bIsObject) {
|
|
|
- Diag(pAttr->getLoc(), diag::err_hlsl_varmodifierna)
|
|
|
- << pAttr->getName() << "non-UAV type";
|
|
|
- result = false;
|
|
|
- }
|
|
|
+ case AttributeList::AT_HLSLGloballyCoherent: // Handled elsewhere
|
|
|
break;
|
|
|
case AttributeList::AT_HLSLUniform:
|
|
|
if (!(isGlobal || isParameter)) {
|