bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [PATCH 4/6] gnulib-common: update for gcc -Wmismatched-dealloc
Date: Sat, 31 Jul 2021 12:01:21 -0700	[thread overview]
Message-ID: <20210731190124.279622-4-eggert@cs.ucla.edu> (raw)
In-Reply-To: <20210731190124.279622-1-eggert@cs.ucla.edu>

* 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  <eggert@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



  parent reply	other threads:[~2021-07-31 19:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31 19:01 [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Paul Eggert
2021-07-31 19:01 ` [PATCH 2/6] manywarnings: document GCC 11 warnings Paul Eggert
2021-07-31 19:01 ` [PATCH 3/6] gnulib-common: update for C2x 2020-12-11 draft Paul Eggert
2021-07-31 19:01 ` Paul Eggert [this message]
2021-07-31 19:01 ` [PATCH 5/6] xalloc: add malloc-related function attributes Paul Eggert
2021-07-31 19:01 ` [PATCH 6/6] doc: C2X -> C2x Paul Eggert
2021-08-01 13:38 ` [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210731190124.279622-4-eggert@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).