bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regression in gnulib 48ece5c3f/gcc 11


From: Bruno Haible
Subject: Re: Regression in gnulib 48ece5c3f/gcc 11
Date: Sun, 22 Aug 2021 23:56:38 +0200

[CCing bug-gnulib.]

Jan Engelhardt wrote in private email:
> I would like to point you to https://github.com/paul-j-lucas/cdecl/issues/12
> from which I gathered that gnulib's stdlib.in.h received a change (48ece5c3f)
> by you that added this part that breaks on gcc11 systems:
> 
> 
> +# if __GNUC__ >= 11 && !defined strdup
> +/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free.  */
> +_GL_FUNCDECL_SYS (strdup, char *,
> +                  (char const *__s)
> +                  _GL_ARG_NONNULL ((1))
> +                  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
> +# endif
> 
> 
> _GL_ATTRIBUTE_MALLOC was not defined in the file, and so leads to a compile
> error. Note how the file *does* define a fallback for _GL_ATTRIBUTE_PURE, 
> which
> is why the compiler did not stumble upon that name first.

Thanks for the report. Formally, this is not a supported situation
because the documentation [1] says that you need to #include <config.h> before
including any .h file from Gnulib. Nevertheless we strive to make the generated
.h files be as standalone (that means, independent from <config.h>) as possible.
The patch below catches up on this property.

[1] https://www.gnu.org/software/gnulib/manual/html_node/Source-changes.html


2021-08-22  Bruno Haible  <bruno@clisp.org>

        Make generated .in.h files as standalone as possible.
        Reported by Jan Engelhardt <jengelh@inai.de>.
        * lib/stdlib.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
        _GL_ATTRIBUTE_MALLOC): Add fallback definitions.
        * lib/dirent.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC): Add
        fallback definitions.
        * lib/stdio.in.h (_GL_ATTRIBUTE_DEALLOC): Add fallback definition.
        * lib/math.in.h (_GL_ATTRIBUTE_CONST): Add fallback definition.
        * lib/pthread.in.h (_GL_ATTRIBUTE_PURE): Add fallback definition.
        * lib/threads.in.h (_GL_ATTRIBUTE_PURE): Likewise.
        * lib/uchar.in.h (_GL_ATTRIBUTE_PURE): Likewise.
        * lib/string.in.h (_GL_ATTRIBUTE_PURE): Move definition, for consistency
        with the other *.in.h files.
        * lib/se-context.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Add fallback
        definition.
        * lib/se-label.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Likewise.
        * lib/se-selinux.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Likewise.
        * lib/textstyle.in.h: Use _GL_ATTRIBUTE_MAYBE_UNUSED instead of
        _GL_UNUSED.
        (_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_MAYBE_UNUSED): Add
        fallback definitions.

diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 5775edf09..4deb0cb46 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -55,6 +55,28 @@ typedef struct gl_directory DIR;
 # endif
 #endif
 
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+   that can be freed by passing them as the Ith argument to the
+   function F.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+#  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+#  define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+   allocated memory.  */
+/* Applies to: functions.  */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+#  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The attribute __pure__ was added in gcc 2.96.  */
 #ifndef _GL_ATTRIBUTE_PURE
diff --git a/lib/math.in.h b/lib/math.in.h
index 6a055fbf5..c87cc12fc 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -56,6 +56,16 @@ _GL_INLINE_HEADER_BEGIN
 # define _GL_MATH_INLINE _GL_INLINE
 #endif
 
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The attribute __const__ was added in gcc 2.95.  */
+#ifndef _GL_ATTRIBUTE_CONST
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined 
__clang__
+#  define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
+# else
+#  define _GL_ATTRIBUTE_CONST /* empty */
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index c4cd36c12..65693d5d1 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -69,6 +69,16 @@
 #include <sys/types.h>
 #include <time.h>
 
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The attribute __pure__ was added in gcc 2.96.  */
+#ifndef _GL_ATTRIBUTE_PURE
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined 
__clang__
+#  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+#  define _GL_ATTRIBUTE_PURE /* empty */
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _Noreturn is copied here.  */
diff --git a/lib/se-context.in.h b/lib/se-context.in.h
index d4ed6a4c1..a6c178ad6 100644
--- a/lib/se-context.in.h
+++ b/lib/se-context.in.h
@@ -29,6 +29,19 @@ _GL_INLINE_HEADER_BEGIN
 # define SE_CONTEXT_INLINE _GL_INLINE
 #endif
 
+/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
+   the entity is not used.  The compiler should not warn if the entity is not
+   used.  */
+#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
+# if 0 /* no GCC or clang version supports this yet */
+#  define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
+# elif defined __GNUC__ || defined __clang__
+#  define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
+# else
+#  define _GL_ATTRIBUTE_MAYBE_UNUSED
+# endif
+#endif
+
 typedef int context_t;
 SE_CONTEXT_INLINE context_t
 context_new (_GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
diff --git a/lib/se-label.in.h b/lib/se-label.in.h
index 2bf1eb88c..c3d19816a 100644
--- a/lib/se-label.in.h
+++ b/lib/se-label.in.h
@@ -31,6 +31,19 @@ _GL_INLINE_HEADER_BEGIN
 # define SE_LABEL_INLINE _GL_INLINE
 #endif
 
+/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
+   the entity is not used.  The compiler should not warn if the entity is not
+   used.  */
+#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
+# if 0 /* no GCC or clang version supports this yet */
+#  define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
+# elif defined __GNUC__ || defined __clang__
+#  define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
+# else
+#  define _GL_ATTRIBUTE_MAYBE_UNUSED
+# endif
+#endif
+
 #define SELABEL_CTX_FILE 0
 
 struct selabel_handle;
diff --git a/lib/se-selinux.in.h b/lib/se-selinux.in.h
index 85dae1181..171870d29 100644
--- a/lib/se-selinux.in.h
+++ b/lib/se-selinux.in.h
@@ -38,6 +38,19 @@ _GL_INLINE_HEADER_BEGIN
 #   define SE_SELINUX_INLINE _GL_INLINE
 #  endif
 
+/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
+   the entity is not used.  The compiler should not warn if the entity is not
+   used.  */
+#  ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
+#   if 0 /* no GCC or clang version supports this yet */
+#    define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
+#   elif defined __GNUC__ || defined __clang__
+#    define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
+#   else
+#    define _GL_ATTRIBUTE_MAYBE_UNUSED
+#   endif
+#  endif
+
 #  if !GNULIB_defined_security_types
 
 typedef unsigned short security_class_t;
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index f1bf81732..0ca2c8e10 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -56,6 +56,52 @@
    May also define off_t to a 64-bit type on native Windows.  */
 #include <sys/types.h>
 
+/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. 
 */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || 
defined __NetBSD__) \
+    && ! defined __GLIBC__
+# include <unistd.h>
+#endif
+
+/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
+    && ! defined __GLIBC__
+# include <sys/stat.h>
+#endif
+
+/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>.  We must include
+   it before we  #define perror rpl_perror.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
+    && (defined _WIN32 && ! defined __CYGWIN__) \
+    && ! defined __GLIBC__
+# include <stdlib.h>
+#endif
+
+/* MSVC declares 'remove' in <io.h>, not in <stdio.h>.  We must include
+   it before we  #define remove rpl_remove.  */
+/* MSVC declares 'rename' in <io.h>, not in <stdio.h>.  We must include
+   it before we  #define rename rpl_rename.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
+    && (defined _WIN32 && ! defined __CYGWIN__) \
+    && ! defined __GLIBC__
+# include <io.h>
+#endif
+
+
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+   that can be freed by passing them as the Ith argument to the
+   function F.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+#  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+#  define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The __-protected variants of the attributes 'format' and 'printf' are
    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
@@ -127,41 +173,6 @@
 #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, 
first_argument) \
   _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
 
-/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. 
 */
-/* But in any case avoid namespace pollution on glibc systems.  */
-#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || 
defined __NetBSD__) \
-    && ! defined __GLIBC__
-# include <unistd.h>
-#endif
-
-/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>.  */
-/* But in any case avoid namespace pollution on glibc systems.  */
-#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
-    && ! defined __GLIBC__
-# include <sys/stat.h>
-#endif
-
-/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>.  We must include
-   it before we  #define perror rpl_perror.  */
-/* But in any case avoid namespace pollution on glibc systems.  */
-#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
-    && (defined _WIN32 && ! defined __CYGWIN__) \
-    && ! defined __GLIBC__
-# include <stdlib.h>
-#endif
-
-/* MSVC declares 'remove' in <io.h>, not in <stdio.h>.  We must include
-   it before we  #define remove rpl_remove.  */
-/* MSVC declares 'rename' in <io.h>, not in <stdio.h>.  We must include
-   it before we  #define rename rpl_rename.  */
-/* But in any case avoid namespace pollution on glibc systems.  */
-#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
-    && (defined _WIN32 && ! defined __CYGWIN__) \
-    && ! defined __GLIBC__
-# include <io.h>
-#endif
-
-
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index d86a88071..d0ea07f8b 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -99,6 +99,35 @@ struct random_data
 # include <unistd.h>
 #endif
 
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+   that can be freed by passing them as the Ith argument to the
+   function F.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+#  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+#  define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+   can be freed via 'free'; it can be used only after including <stdlib.h>.  */
+/* Applies to: functions.  Cannot be used on inline functions.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+   allocated memory.  */
+/* Applies to: functions.  */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+#  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The attribute __pure__ was added in gcc 2.96.  */
 #ifndef _GL_ATTRIBUTE_PURE
diff --git a/lib/string.in.h b/lib/string.in.h
index b043c7522..fa2e40c25 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -55,16 +55,6 @@
 # include <wchar.h>
 #endif
 
-/* The __attribute__ feature is available in gcc versions 2.5 and later.
-   The attribute __pure__ was added in gcc 2.96.  */
-#ifndef _GL_ATTRIBUTE_PURE
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined 
__clang__
-#  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
-# else
-#  define _GL_ATTRIBUTE_PURE /* empty */
-# endif
-#endif
-
 /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */
 /* But in any case avoid namespace pollution on glibc systems.  */
 #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
@@ -80,6 +70,16 @@
 # include <strings.h>
 #endif
 
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The attribute __pure__ was added in gcc 2.96.  */
+#ifndef _GL_ATTRIBUTE_PURE
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined 
__clang__
+#  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+#  define _GL_ATTRIBUTE_PURE /* empty */
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
diff --git a/lib/textstyle.in.h b/lib/textstyle.in.h
index a160cda48..2b823f1d7 100644
--- a/lib/textstyle.in.h
+++ b/lib/textstyle.in.h
@@ -42,6 +42,32 @@
 # include <termios.h>
 #endif
 
+/* An __attribute__ __format__ specifier for a function that takes a format
+   string and arguments, where the format string directives are the ones
+   standardized by ISO C99 and POSIX.
+   _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD  */
+/* __gnu_printf__ is supported in GCC >= 4.4.  */
+#ifndef _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
+# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+#  define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
+# else
+#  define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
+   the entity is not used.  The compiler should not warn if the entity is not
+   used.  */
+#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
+# if 0 /* no GCC or clang version supports this yet */
+#  define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
+# elif defined __GNUC__ || defined __clang__
+#  define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
+# else
+#  define _GL_ATTRIBUTE_MAYBE_UNUSED
+# endif
+#endif
+
 /* ----------------------------- From ostream.h ----------------------------- 
*/
 
 /* Describes the scope of a flush operation.  */
@@ -167,38 +193,38 @@ typedef ostream_t styled_ostream_t;
 #define styled_ostream_free ostream_free
 
 static inline void
-styled_ostream_begin_use_class (_GL_UNUSED styled_ostream_t stream,
-                                _GL_UNUSED const char *classname)
+styled_ostream_begin_use_class (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t 
stream,
+                                _GL_ATTRIBUTE_MAYBE_UNUSED const char 
*classname)
 {
 }
 
 static inline void
-styled_ostream_end_use_class (_GL_UNUSED styled_ostream_t stream,
-                              _GL_UNUSED const char *classname)
+styled_ostream_end_use_class (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t 
stream,
+                              _GL_ATTRIBUTE_MAYBE_UNUSED const char *classname)
 {
 }
 
 static inline const char *
-styled_ostream_get_hyperlink_ref (_GL_UNUSED styled_ostream_t stream)
+styled_ostream_get_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t 
stream)
 {
   return NULL;
 }
 
 static inline const char *
-styled_ostream_get_hyperlink_id (_GL_UNUSED styled_ostream_t stream)
+styled_ostream_get_hyperlink_id (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t 
stream)
 {
   return NULL;
 }
 
 static inline void
-styled_ostream_set_hyperlink (_GL_UNUSED styled_ostream_t stream,
-                              _GL_UNUSED const char *ref,
-                              _GL_UNUSED const char *id)
+styled_ostream_set_hyperlink (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t 
stream,
+                              _GL_ATTRIBUTE_MAYBE_UNUSED const char *ref,
+                              _GL_ATTRIBUTE_MAYBE_UNUSED const char *id)
 {
 }
 
 static inline void
-styled_ostream_flush_to_current_style (_GL_UNUSED styled_ostream_t stream)
+styled_ostream_flush_to_current_style (_GL_ATTRIBUTE_MAYBE_UNUSED 
styled_ostream_t stream)
 {
 }
 
@@ -225,8 +251,8 @@ typedef ostream_t fd_ostream_t;
 #define fd_ostream_free ostream_free
 
 static inline fd_ostream_t
-fd_ostream_create (int fd, _GL_UNUSED const char *filename,
-                   _GL_UNUSED bool buffered)
+fd_ostream_create (int fd, _GL_ATTRIBUTE_MAYBE_UNUSED const char *filename,
+                   _GL_ATTRIBUTE_MAYBE_UNUSED bool buffered)
 {
   if (fd == 1)
     return stdout;
@@ -272,81 +298,81 @@ typedef ostream_t term_ostream_t;
 #define term_ostream_free ostream_free
 
 static inline term_color_t
-term_ostream_get_color (_GL_UNUSED term_ostream_t stream)
+term_ostream_get_color (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream)
 {
   return COLOR_DEFAULT;
 }
 
 static inline void
-term_ostream_set_color (_GL_UNUSED term_ostream_t stream,
-                        _GL_UNUSED term_color_t color)
+term_ostream_set_color (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream,
+                        _GL_ATTRIBUTE_MAYBE_UNUSED term_color_t color)
 {
 }
 
 static inline term_color_t
-term_ostream_get_bgcolor (_GL_UNUSED term_ostream_t stream)
+term_ostream_get_bgcolor (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream)
 {
   return COLOR_DEFAULT;
 }
 
 static inline void
-term_ostream_set_bgcolor (_GL_UNUSED term_ostream_t stream,
-                          _GL_UNUSED term_color_t color)
+term_ostream_set_bgcolor (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream,
+                          _GL_ATTRIBUTE_MAYBE_UNUSED term_color_t color)
 {
 }
 
 static inline term_weight_t
-term_ostream_get_weight (_GL_UNUSED term_ostream_t stream)
+term_ostream_get_weight (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream)
 {
   return WEIGHT_DEFAULT;
 }
 
 static inline void
-term_ostream_set_weight (_GL_UNUSED term_ostream_t stream,
-                         _GL_UNUSED term_weight_t weight)
+term_ostream_set_weight (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream,
+                         _GL_ATTRIBUTE_MAYBE_UNUSED term_weight_t weight)
 {
 }
 
 static inline term_posture_t
-term_ostream_get_posture (_GL_UNUSED term_ostream_t stream)
+term_ostream_get_posture (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream)
 {
   return POSTURE_DEFAULT;
 }
 
 static inline void
-term_ostream_set_posture (_GL_UNUSED term_ostream_t stream,
-                          _GL_UNUSED term_posture_t posture)
+term_ostream_set_posture (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream,
+                          _GL_ATTRIBUTE_MAYBE_UNUSED term_posture_t posture)
 {
 }
 
 static inline term_underline_t
-term_ostream_get_underline (_GL_UNUSED term_ostream_t stream)
+term_ostream_get_underline (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream)
 {
   return UNDERLINE_DEFAULT;
 }
 
 static inline void
-term_ostream_set_underline (_GL_UNUSED term_ostream_t stream,
-                            _GL_UNUSED term_underline_t underline)
+term_ostream_set_underline (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream,
+                            _GL_ATTRIBUTE_MAYBE_UNUSED term_underline_t 
underline)
 {
 }
 
 static inline const char *
-term_ostream_get_hyperlink_ref (_GL_UNUSED term_ostream_t stream)
+term_ostream_get_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t 
stream)
 {
   return NULL;
 }
 
 static inline const char *
-term_ostream_get_hyperlink_id (_GL_UNUSED term_ostream_t stream)
+term_ostream_get_hyperlink_id (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t 
stream)
 {
   return NULL;
 }
 
 static inline void
-term_ostream_set_hyperlink (_GL_UNUSED term_ostream_t stream,
-                            _GL_UNUSED const char *ref,
-                            _GL_UNUSED const char *id)
+term_ostream_set_hyperlink (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream,
+                            _GL_ATTRIBUTE_MAYBE_UNUSED const char *ref,
+                            _GL_ATTRIBUTE_MAYBE_UNUSED const char *id)
 {
 }
 
@@ -374,7 +400,7 @@ typedef enum
 
 static inline term_ostream_t
 term_ostream_create (int fd, const char *filename,
-                     _GL_UNUSED ttyctl_t tty_control)
+                     _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control)
 {
   return fd_ostream_create (fd, filename, true);
 }
@@ -395,8 +421,8 @@ typedef styled_ostream_t term_styled_ostream_t;
 
 static inline term_styled_ostream_t
 term_styled_ostream_create (int fd, const char *filename,
-                            _GL_UNUSED ttyctl_t tty_control,
-                            _GL_UNUSED const char *css_filename)
+                            _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control,
+                            _GL_ATTRIBUTE_MAYBE_UNUSED const char 
*css_filename)
 {
   return fd_ostream_create (fd, filename, true);
 }
@@ -406,8 +432,8 @@ term_styled_ostream_create (int fd, const char *filename,
 typedef styled_ostream_t html_styled_ostream_t;
 
 static inline html_styled_ostream_t
-html_styled_ostream_create (_GL_UNUSED ostream_t destination,
-                            _GL_UNUSED const char *css_filename)
+html_styled_ostream_create (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t destination,
+                            _GL_ATTRIBUTE_MAYBE_UNUSED const char 
*css_filename)
 {
   abort ();
   return NULL;
@@ -423,13 +449,13 @@ enum color_option { color_no, color_tty, color_yes, 
color_html };
 #define style_file_name NULL
 
 static inline bool
-handle_color_option (_GL_UNUSED const char *option)
+handle_color_option (_GL_ATTRIBUTE_MAYBE_UNUSED const char *option)
 {
   return false;
 }
 
 static inline void
-handle_style_option (_GL_UNUSED const char *option)
+handle_style_option (_GL_ATTRIBUTE_MAYBE_UNUSED const char *option)
 {
 }
 
@@ -440,10 +466,10 @@ print_color_test (void)
 }
 
 static inline void
-style_file_prepare (_GL_UNUSED const char *style_file_envvar,
-                    _GL_UNUSED const char *stylesdir_envvar,
-                    _GL_UNUSED const char *stylesdir_after_install,
-                    _GL_UNUSED const char *default_style_file)
+style_file_prepare (_GL_ATTRIBUTE_MAYBE_UNUSED const char *style_file_envvar,
+                    _GL_ATTRIBUTE_MAYBE_UNUSED const char *stylesdir_envvar,
+                    _GL_ATTRIBUTE_MAYBE_UNUSED const char 
*stylesdir_after_install,
+                    _GL_ATTRIBUTE_MAYBE_UNUSED const char *default_style_file)
 {
 }
 
@@ -451,14 +477,14 @@ style_file_prepare (_GL_UNUSED const char 
*style_file_envvar,
 
 static inline styled_ostream_t
 styled_ostream_create (int fd, const char *filename,
-                       _GL_UNUSED ttyctl_t tty_control,
-                       _GL_UNUSED const char *css_filename)
+                       _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control,
+                       _GL_ATTRIBUTE_MAYBE_UNUSED const char *css_filename)
 {
   return fd_ostream_create (fd, filename, true);
 }
 
 static inline void
-libtextstyle_set_failure_exit_code (_GL_UNUSED int exit_code)
+libtextstyle_set_failure_exit_code (_GL_ATTRIBUTE_MAYBE_UNUSED int exit_code)
 {
 }
 
diff --git a/lib/threads.in.h b/lib/threads.in.h
index 4e4be3e59..b1706637f 100644
--- a/lib/threads.in.h
+++ b/lib/threads.in.h
@@ -49,6 +49,16 @@
 
 #endif
 
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The attribute __pure__ was added in gcc 2.96.  */
+#ifndef _GL_ATTRIBUTE_PURE
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined 
__clang__
+#  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+#  define _GL_ATTRIBUTE_PURE /* empty */
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _Noreturn is copied here.  */
diff --git a/lib/uchar.in.h b/lib/uchar.in.h
index a03231e17..29086defb 100644
--- a/lib/uchar.in.h
+++ b/lib/uchar.in.h
@@ -37,6 +37,16 @@
 /* Get mbstate_t, size_t.  */
 #include <wchar.h>
 
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The attribute __pure__ was added in gcc 2.96.  */
+#ifndef _GL_ATTRIBUTE_PURE
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined 
__clang__
+#  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+#  define _GL_ATTRIBUTE_PURE /* empty */
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]