[clang] [HLSL] Add support for groupshared args (PR #181886)

Sarah Spall via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 9 19:17:13 PDT 2026


================
@@ -788,6 +788,18 @@ static void instantiateDependentHLSLParamModifierAttr(
   ParmVarDecl *NewParm = cast<ParmVarDecl>(New);
   NewParm->addAttr(Attr->clone(S.getASTContext()));
 
+  // If this is groupshared don't change the type because it will assert
+  // below. In this case we might have already produced an error but we
+  // must produce one here again because of all the ways templates can
+  // be used.
+  if (const auto *RT = NewParm->getType()->getAs<LValueReferenceType>()) {
+    if (RT->getPointeeType().getAddressSpace() == LangAS::hlsl_groupshared) {
+      S.Diag(Attr->getLoc(), diag::err_hlsl_attr_incompatible)
+          << Attr << "'groupshared'";
----------------
spall wrote:

So this isn't a regular attr with a setinvalid function , its an HLSLParamModifierAttr and it can't be set to invalid.

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


More information about the cfe-commits mailing list