Re: [PATCH 1/2] Compiler Attributes: Add __access macro
From: David Laight
Date: Wed Apr 22 2026 - 09:34:38 EST
On Wed, 22 Apr 2026 12:25:26 +0200
Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> wrote:
> On Tue, Apr 21, 2026 at 9:30 PM Arnd Bergmann <arnd@xxxxxxxx> wrote:
> >
> > gcc-10 knows the 'access' attribute, but not the 'none' variant:
> >
> > echo 'int f(void *p) __attribute__((access(none, 1)));' | /home/arnd/cross/arm64/gcc-10.5.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc -xc - -o /dev/null -c
> > <stdin>:1:1: error: attribute 'access' invalid mode 'none'; expected one of 'read_only', 'read_write', or 'write_only'
>
> Which is exactly the one we use in #2, indeed.
>
> That makes sense, thanks!
>
> We should still change the number here, because `__has_attribute` will
> pass even with GCC 10, i.e. since someone using `none` without a gate
> in Kconfig or elsewhere may not realize the mistake.
>
> So we should probably add a comment that the access mode `none` is
> only available in GCC 11 -- especially so if we add the docs David
> suggests, because otherwise it seems like it is supported.
Especially since the gcc docs make it pretty impossible to find out when
anything was added. Trial and error on godbolt shouldn't really be needed.
(and I missed that the size/count is the argument number as well).
David
>
> Cheers,
> Miguel
>