[clang] [SemaHLSL] Add missing validations of existing semantics (PR #224139)

Finn Plummer via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 25 10:46:38 PDT 2026


================
@@ -913,7 +913,18 @@ bool SemaHLSL::determineActiveSemanticOnScalar(FunctionDecl *FD,
   if (!A)
     return false;
 
-  checkSemanticAnnotation(FD, D, A, SC);
+  // Each array element occupies a separate semantic index.
+  QualType T = D == FD ? FD->getReturnType() : D->getType();
+  const ConstantArrayType *AT =
+      getASTContext().getAsConstantArrayType(T.getNonReferenceType());
+  if (isZeroSizedArray(AT)) {
+    Diag(A->getLoc(), diag::err_hlsl_semantic_zero_sized_array)
+        << A->getAttrName();
+    return false;
+  }
+  unsigned ElementCount = AT ? ASTContext::getConstantArrayElementCount(AT) : 1;
----------------
inbelic wrote:

Good catch, note that 64-bit component types are actually not allowed when targeting DXIL so the current index overlap analysis holds now that I have added a diag for 64 bit component types

https://github.com/llvm/llvm-project/pull/224139


More information about the cfe-commits mailing list