[clang] [clang][Sema] Handle alloc_align on all HasFunctionProto declarations (PR #210871)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 21 07:51:07 PDT 2026


================
@@ -1509,16 +1509,15 @@ void Sema::AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
   }
 
   ParamIdx Idx;
-  const auto *FuncDecl = cast<FunctionDecl>(D);
-  if (!checkFunctionOrMethodParameterIndex(FuncDecl, CI,
+  if (!checkFunctionOrMethodParameterIndex(D, CI,
                                            /*AttrArgNum=*/1, ParamExpr, Idx))
     return;
 
   QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex());
   if (!Ty->isDependentType() && !Ty->isIntegralType(Context) &&
       !Ty->isAlignValT()) {
     Diag(ParamExpr->getBeginLoc(), diag::err_attribute_integers_only)
-        << CI << FuncDecl->getParamDecl(Idx.getASTIndex())->getSourceRange();
+        << CI << getFunctionOrMethodParamRange(D, Idx.getASTIndex());
----------------
erichkeane wrote:

`D` is a ParmDecl` here.  So it is none of those 3 things, so this returns `SourceRange`.  it is 'has a function prototype' because it is a function pointer.

See:
`void aa_fn_ptr(char* (*member)(char*)  __attribute__((alloc_align(1))));`

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


More information about the cfe-commits mailing list