[PATCH] D55212: Handle alloc_size attribute on function pointers

Alexander Richardson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 3 12:23:33 PST 2018


arichardson marked an inline comment as done.
arichardson added a comment.

Thanks for the review! I'll write a C++ test tomorrow.



================
Comment at: include/clang/Basic/Attr.td:1072
 def AllocSize : InheritableAttr {
   let Spellings = [GCC<"alloc_size">];
+  let Subjects = SubjectList<[HasFunctionProto]>;
----------------
aaron.ballman wrote:
> arichardson wrote:
> > aaron.ballman wrote:
> > > Does GCC support writing `alloc_size` on function pointers?
> > Yes it does and it seems to be used by some projects. I first discovered this while compiling libxml2: https://github.com/GNOME/libxml2/blob/35e83488505d501864826125cfe6a7950d6cba78/include/libxml/xmlmemory.h#L66
> Parsed and ignored is different than supported. For instance, I can't seem to get GCC to produce different behavior here: https://godbolt.org/z/MI5k_m
> 
> Am I missing something?
Ah yes, it does seem like it is ignored. I assumed it would work for GCC since it handles, e.g. the format attribute on function pointers.

However, I would like it if we could support it on function pointers even if GCC just ignores is.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55212/new/

https://reviews.llvm.org/D55212





More information about the cfe-commits mailing list