* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macros _GL_ATTRIBUTE_DEALLOC and _GL_ATTRIBUTE_DEALLOC_FREE. These can be useful with gcc -Wmismatched-dealloc. --- ChangeLog | 5 +++++ m4/gnulib-common.m4 | 12 ++++++++++++ 2 files changed, 17 insertions(+)
diff --git a/ChangeLog b/ChangeLog index 7e388c4dd..33a472f5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2021-07-30 Paul Eggert <egg...@cs.ucla.edu> + gnulib-common: update for gcc -Wmismatched-dealloc + * m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macros + _GL_ATTRIBUTE_DEALLOC and _GL_ATTRIBUTE_DEALLOC_FREE. These can + be useful with gcc -Wmismatched-dealloc. + gnulib-common: update for C2x 2020-12-11 draft Use blessed-by-draft-standard way to test for [[__deprecated__]] etc.; this is supported by GCC 11 and the fallback code should diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 347462d1d..2872ecdf7 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -148,6 +148,18 @@ AC_DEFUN([gl_COMMON_BODY], [ # define _GL_ATTRIBUTE_CONST #endif +/* _GL_ATTRIBUTE_DEALLOC (F, I) is for functions returning pointers + that can be freed by passing them as the Ith argument to the + function F. _GL_ATTRIBUTE_DEALLOC_FREE is for functions that + return pointers that can be freed via 'free'; it can be used + only after including stdlib.h. */ +#if _GL_GNUC_PREREQ (11, 0) +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +#else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +#endif +#define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) + #if _GL_HAS_C_ATTRIBUTE (deprecated) # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] #elif _GL_HAS_ATTRIBUTE (deprecated) -- 2.31.1