These patches enable the use of the 'attribute' module in a couple of more
places. And fix a typo.


2020-05-08  Bruno Haible  <br...@clisp.org>

        ignore-value tests: Use module 'attribute'.
        * m4/gnulib-common.m4 (gl_COMMON_BODY): Fix a typo.
        * tests/test-ignore-value.c: Include attribute.h.
        (_GL_ATTRIBUTE_RETURN_CHECK): Remove macro. Use NODISCARD instead.
        * modules/ignore-value-tests (Depends-on): Add attribute.

2020-05-08  Bruno Haible  <br...@clisp.org>

        uniname/uniname: Use module 'attribute'.
        * lib/uniname/gen-uninames.lisp: Emit a reference to ATTRIBUTE_PACKED.
        * lib/uniname/uninames.h: Regenerated.
        * lib/uniname/uniname.c: Include attribute.h.
        * modules/uniname/uniname (Depends-on): Add attribute.

2020-05-08  Bruno Haible  <br...@clisp.org>

        c32rtomb: Use module 'attribute'.
        * lib/c32rtomb.c: Include attribute.h.
        (FALLTHROUGH): Remove macro.
        * modules/c32rtomb (Depends-on): Add attribute.

2020-05-08  Bruno Haible  <br...@clisp.org>

        xsize: Use module 'attribute'.
        * lib/xsize.h: Include attribute.h. Use ATTRIBUTE_PURE.
        * modules/xsize (Depends-on): Add attribute.

>From 5cbf341390d5f4bd81af154b8aab77fbe31d08ac Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 8 May 2020 18:05:35 +0200
Subject: [PATCH 1/4] xsize: Use module 'attribute'.

* lib/xsize.h: Include attribute.h. Use ATTRIBUTE_PURE.
* modules/xsize (Depends-on): Add attribute.
---
 ChangeLog     |  6 ++++++
 lib/xsize.h   | 23 +++++++----------------
 modules/xsize |  1 +
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0e0cc81..df4f5d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-08  Bruno Haible  <br...@clisp.org>
+
+	xsize: Use module 'attribute'.
+	* lib/xsize.h: Include attribute.h. Use ATTRIBUTE_PURE.
+	* modules/xsize (Depends-on): Add attribute.
+
 2020-05-06  Paul Eggert  <egg...@cs.ucla.edu>
 
 	* m4/gnulib-common.m4 (gl_COMMON_BODY): Minor style fixes.
diff --git a/lib/xsize.h b/lib/xsize.h
index cd12677..8e5f14c 100644
--- a/lib/xsize.h
+++ b/lib/xsize.h
@@ -27,6 +27,9 @@
 # include <stdint.h>
 #endif
 
+/* Get ATTRIBUTE_PURE.  */
+#include "attribute.h"
+
 #ifndef _GL_INLINE_HEADER_BEGIN
  #error "Please include config.h first."
 #endif
@@ -56,10 +59,7 @@ _GL_INLINE_HEADER_BEGIN
   ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
 
 /* Sum of two sizes, with overflow check.  */
-XSIZE_INLINE size_t
-#if __GNUC__ >= 3
-__attribute__ ((__pure__))
-#endif
+XSIZE_INLINE size_t ATTRIBUTE_PURE
 xsum (size_t size1, size_t size2)
 {
   size_t sum = size1 + size2;
@@ -67,30 +67,21 @@ xsum (size_t size1, size_t size2)
 }
 
 /* Sum of three sizes, with overflow check.  */
-XSIZE_INLINE size_t
-#if __GNUC__ >= 3
-__attribute__ ((__pure__))
-#endif
+XSIZE_INLINE size_t ATTRIBUTE_PURE
 xsum3 (size_t size1, size_t size2, size_t size3)
 {
   return xsum (xsum (size1, size2), size3);
 }
 
 /* Sum of four sizes, with overflow check.  */
-XSIZE_INLINE size_t
-#if __GNUC__ >= 3
-__attribute__ ((__pure__))
-#endif
+XSIZE_INLINE size_t ATTRIBUTE_PURE
 xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
 {
   return xsum (xsum (xsum (size1, size2), size3), size4);
 }
 
 /* Maximum of two sizes, with overflow check.  */
-XSIZE_INLINE size_t
-#if __GNUC__ >= 3
-__attribute__ ((__pure__))
-#endif
+XSIZE_INLINE size_t ATTRIBUTE_PURE
 xmax (size_t size1, size_t size2)
 {
   /* No explicit check is needed here, because for any n:
diff --git a/modules/xsize b/modules/xsize
index a13eb86..3b2ad56 100644
--- a/modules/xsize
+++ b/modules/xsize
@@ -7,6 +7,7 @@ lib/xsize.c
 m4/xsize.m4
 
 Depends-on:
+attribute
 extern-inline
 size_max
 
-- 
2.7.4

>From 9b9649b8098529adfec2ff2e93fddab0637cfdfa Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 8 May 2020 18:07:17 +0200
Subject: [PATCH 2/4] c32rtomb: Use module 'attribute'.

* lib/c32rtomb.c: Include attribute.h.
(FALLTHROUGH): Remove macro.
* modules/c32rtomb (Depends-on): Add attribute.
---
 ChangeLog        | 7 +++++++
 lib/c32rtomb.c   | 9 +--------
 modules/c32rtomb | 1 +
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df4f5d1..43946e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2020-05-08  Bruno Haible  <br...@clisp.org>
 
+	c32rtomb: Use module 'attribute'.
+	* lib/c32rtomb.c: Include attribute.h.
+	(FALLTHROUGH): Remove macro.
+	* modules/c32rtomb (Depends-on): Add attribute.
+
+2020-05-08  Bruno Haible  <br...@clisp.org>
+
 	xsize: Use module 'attribute'.
 	* lib/xsize.h: Include attribute.h. Use ATTRIBUTE_PURE.
 	* modules/xsize (Depends-on): Add attribute.
diff --git a/lib/c32rtomb.c b/lib/c32rtomb.c
index ba39929..8e4fb56 100644
--- a/lib/c32rtomb.c
+++ b/lib/c32rtomb.c
@@ -24,17 +24,10 @@
 #include <errno.h>
 #include <wchar.h>
 
+#include "attribute.h" /* FALLTHROUGH */
 #include "localcharset.h"
 #include "streq.h"
 
-#ifndef FALLTHROUGH
-# if __GNUC__ < 7
-#  define FALLTHROUGH ((void) 0)
-# else
-#  define FALLTHROUGH __attribute__ ((__fallthrough__))
-# endif
-#endif
-
 size_t
 c32rtomb (char *s, char32_t wc, mbstate_t *ps)
 #undef c32rtomb
diff --git a/modules/c32rtomb b/modules/c32rtomb
index ea227df..9863d70 100644
--- a/modules/c32rtomb
+++ b/modules/c32rtomb
@@ -8,6 +8,7 @@ m4/mbrtoc32.m4
 
 Depends-on:
 uchar
+attribute       [test $HAVE_C32RTOMB = 0 || test $REPLACE_C32RTOMB = 1]
 wchar           [test $HAVE_C32RTOMB = 0 || test $REPLACE_C32RTOMB = 1]
 wcrtomb         [test $HAVE_C32RTOMB = 0 || test $REPLACE_C32RTOMB = 1]
 localcharset    [{ test $HAVE_C32RTOMB = 0 || test $REPLACE_C32RTOMB = 1; } && test $SMALL_WCHAR_T = 1]
-- 
2.7.4

>From 8169e7f19baa6f1ba94ecfb4a1048c2d46eb644d Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 8 May 2020 18:09:23 +0200
Subject: [PATCH 3/4] uniname/uniname: Use module 'attribute'.

* lib/uniname/gen-uninames.lisp: Emit a reference to ATTRIBUTE_PACKED.
* lib/uniname/uninames.h: Regenerated.
* lib/uniname/uniname.c: Include attribute.h.
* modules/uniname/uniname (Depends-on): Add attribute.
---
 ChangeLog                     |  8 ++++++++
 lib/uniname/gen-uninames.lisp |  8 ++------
 lib/uniname/uniname.c         |  2 ++
 lib/uniname/uninames.h        | 12 ++----------
 modules/uniname/uniname       |  1 +
 5 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 43946e0..56c15bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2020-05-08  Bruno Haible  <br...@clisp.org>
 
+	uniname/uniname: Use module 'attribute'.
+	* lib/uniname/gen-uninames.lisp: Emit a reference to ATTRIBUTE_PACKED.
+	* lib/uniname/uninames.h: Regenerated.
+	* lib/uniname/uniname.c: Include attribute.h.
+	* modules/uniname/uniname (Depends-on): Add attribute.
+
+2020-05-08  Bruno Haible  <br...@clisp.org>
+
 	c32rtomb: Use module 'attribute'.
 	* lib/c32rtomb.c: Include attribute.h.
 	(FALLTHROUGH): Remove macro.
diff --git a/lib/uniname/gen-uninames.lisp b/lib/uniname/gen-uninames.lisp
index ab46eae..38a798f 100755
--- a/lib/uniname/gen-uninames.lisp
+++ b/lib/uniname/gen-uninames.lisp
@@ -294,9 +294,7 @@
             (incf i (length (unicode-char-word-indices uc)))
         ) )
         (format ostream "};~%")
-        (format ostream "static const struct { uint16_t index; uint32_t name:24; }~%")
-        (format ostream "#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)~%__attribute__((__packed__))~%#endif~%")
-        (format ostream "unicode_name_to_index[~D] = {~%"
+        (format ostream "static const struct { uint16_t index; uint32_t name:24; } ATTRIBUTE_PACKED unicode_name_to_index[~D] = {~%"
                         (length all-chars-and-aliases)
         )
         (dolist (uc all-chars-and-aliases)
@@ -310,9 +308,7 @@
           (format ostream "~%")
         )
         (format ostream "};~%")
-        (format ostream "static const struct { uint16_t index; uint32_t name:24; }~%")
-        (format ostream "#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)~%__attribute__((__packed__))~%#endif~%")
-        (format ostream "unicode_index_to_name[~D] = {~%"
+        (format ostream "static const struct { uint16_t index; uint32_t name:24; } ATTRIBUTE_PACKED unicode_index_to_name[~D] = {~%"
                         (length all-chars)
         )
         (dolist (uc (sort (copy-list all-chars) #'< :key #'unicode-char-index))
diff --git a/lib/uniname/uniname.c b/lib/uniname/uniname.c
index 6f59bdb..7cf1e2e 100644
--- a/lib/uniname/uniname.c
+++ b/lib/uniname/uniname.c
@@ -25,6 +25,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "attribute.h"
+
 #define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
 
 
diff --git a/lib/uniname/uninames.h b/lib/uniname/uninames.h
index 2906ec9..191b353 100644
--- a/lib/uniname/uninames.h
+++ b/lib/uniname/uninames.h
@@ -41108,11 +41108,7 @@ static const uint16_t unicode_names[115981] = {
   23557, 15672,
   23563, 15672,
 };
-static const struct { uint16_t index; uint32_t name:24; }
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
-__attribute__((__packed__))
-#endif
-unicode_name_to_index[29282] = {
+static const struct { uint16_t index; uint32_t name:24; } ATTRIBUTE_PACKED unicode_name_to_index[29282] = {
   { 0x1CA1, 0 },
   { 0x2526, 4 },
   { 0x1EB0, 7 },
@@ -70396,11 +70392,7 @@ unicode_name_to_index[29282] = {
   { 0x1F1B, 115977 },
   { 0x1F1A, 115979 },
 };
-static const struct { uint16_t index; uint32_t name:24; }
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
-__attribute__((__packed__))
-#endif
-unicode_index_to_name[29234] = {
+static const struct { uint16_t index; uint32_t name:24; } ATTRIBUTE_PACKED unicode_index_to_name[29234] = {
   { 0x0000, 34710 },
   { 0x0001, 105577 },
   { 0x0002, 101766 },
diff --git a/modules/uniname/uniname b/modules/uniname/uniname
index 852ba41..bbd8a99 100644
--- a/modules/uniname/uniname
+++ b/modules/uniname/uniname
@@ -8,6 +8,7 @@ lib/uniname/uniname.c
 
 Depends-on:
 uniname/base
+attribute
 memcmp
 
 configure.ac:
-- 
2.7.4

>From fae803d8dc6dae3be9e657b926f11e9a857d7fbb Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 8 May 2020 18:30:01 +0200
Subject: [PATCH 4/4] ignore-value tests: Use module 'attribute'.

* m4/gnulib-common.m4 (gl_COMMON_BODY): Fix a typo.
* tests/test-ignore-value.c: Include attribute.h.
(_GL_ATTRIBUTE_RETURN_CHECK): Remove macro. Use NODISCARD instead.
* modules/ignore-value-tests (Depends-on): Add attribute.
---
 ChangeLog                  |  8 ++++++++
 m4/gnulib-common.m4        |  4 ++--
 modules/ignore-value-tests |  1 +
 tests/test-ignore-value.c  | 18 ++++++------------
 4 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 56c15bc..6f154d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2020-05-08  Bruno Haible  <br...@clisp.org>
 
+	ignore-value tests: Use module 'attribute'.
+	* m4/gnulib-common.m4 (gl_COMMON_BODY): Fix a typo.
+	* tests/test-ignore-value.c: Include attribute.h.
+	(_GL_ATTRIBUTE_RETURN_CHECK): Remove macro. Use NODISCARD instead.
+	* modules/ignore-value-tests (Depends-on): Add attribute.
+
+2020-05-08  Bruno Haible  <br...@clisp.org>
+
 	uniname/uniname: Use module 'attribute'.
 	* lib/uniname/gen-uninames.lisp: Emit a reference to ATTRIBUTE_PACKED.
 	* lib/uniname/uninames.h: Regenerated.
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 7977159..f4ba5e3 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 49
+# gnulib-common.m4 serial 50
 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -96,7 +96,7 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
 # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
 # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
-# define _GL_ATTR_warn_unused_result_GL_GNUC_PREREQ (3, 4)
+# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
 #endif
 
 ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead.
diff --git a/modules/ignore-value-tests b/modules/ignore-value-tests
index 9c8c6d6..855d771 100644
--- a/modules/ignore-value-tests
+++ b/modules/ignore-value-tests
@@ -2,6 +2,7 @@ Files:
 tests/test-ignore-value.c
 
 Depends-on:
+attribute
 stdio
 
 configure.ac:
diff --git a/tests/test-ignore-value.c b/tests/test-ignore-value.c
index f323a7b..9d55115 100644
--- a/tests/test-ignore-value.c
+++ b/tests/test-ignore-value.c
@@ -23,20 +23,14 @@
 
 #include <stdio.h>
 
-#ifndef _GL_ATTRIBUTE_RETURN_CHECK
-# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
-#  define _GL_ATTRIBUTE_RETURN_CHECK
-# else
-#  define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
-# endif
-#endif
+#include "attribute.h"
 
 struct s { int i; };
-static char doChar (void) _GL_ATTRIBUTE_RETURN_CHECK;
-static int doInt (void) _GL_ATTRIBUTE_RETURN_CHECK;
-static off_t doOff (void) _GL_ATTRIBUTE_RETURN_CHECK;
-static void *doPtr (void) _GL_ATTRIBUTE_RETURN_CHECK;
-static struct s doStruct (void) _GL_ATTRIBUTE_RETURN_CHECK;
+static char doChar (void) NODISCARD;
+static int doInt (void) NODISCARD;
+static off_t doOff (void) NODISCARD;
+static void *doPtr (void) NODISCARD;
+static struct s doStruct (void) NODISCARD;
 
 static char
 doChar (void)
-- 
2.7.4

Reply via email to