From 06febd8c6705c816b2f32ee7aa1f4c0184b05248 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 4 May 2020 11:21:50 -0600 Subject: improve out-of-bounds checking with GCC 10 attribute access [BZ #25219] Adds the access attribute newly introduced in GCC 10 to the subset of function declarations that are already covered by _FORTIFY_SOURCE and that don't have corresponding GCC built-in equivalents. Reviewed-by: DJ Delorie --- misc/sys/cdefs.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'misc') diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 9fa371ab86..19d9cc5cfe 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -548,4 +548,15 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf # define __HAVE_GENERIC_SELECTION 0 #endif +#if __GNUC_PREREQ (10, 0) +/* Designates a 1-based positional argument ref-index of pointer type + that can be used to access size-index elements of the pointed-to + array according to access mode, or at least one element when + size-index is not provided: + access (access-mode, [, ]) */ +#define __attr_access(x) __attribute__ ((__access__ x)) +#else +# define __attr_access(x) +#endif + #endif /* sys/cdefs.h */ -- cgit 1.4.1