string: Fix syntax error with g++ 2.96.
authorBruno Haible <bruno@clisp.org>
Wed, 30 Jun 2010 00:19:54 +0000 (02:19 +0200)
committerIan Beckwith <ianb@erislabs.net>
Sun, 4 Jul 2010 01:33:25 +0000 (02:33 +0100)
(cherry picked from commit 7740412b04f93987e9e9c084c2dc86d5366db324)

ChangeLog
lib/string.in.h

index f45cab5..1d38464 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-06-29  Bruno Haible  <bruno@clisp.org>
+
+       string: Fix syntax error with g++ 2.96.
+       * lib/string.in.h (__pure__): Remove definition.
+       (_GL_ATTRIBUTE_PURE): New macro.
+       (memchr, memmem, memrchr, rawmemchr, strchrnul, strnlen, strpbrk,
+       strstr, strcasestr): Use it instead of __attribute__ ((__pure__)).
+       Reported by Christian Weisgerber <naddy@mips.inka.de>.
+
 2010-06-28  Ian Beckwith  <ianb@erislabs.net>
 
        unitypes: Fix bug introduced on 2010-05-18.
index de446b4..ca907b5 100644 (file)
 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
 #  define __attribute__(Spec) /* empty */
 # endif
+#endif
 /* The attribute __pure__ was added in gcc 2.96.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
-#  define __pure__ /* empty */
-# endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+#else
+# define _GL_ATTRIBUTE_PURE /* empty */
 #endif
 
 
 #   define memchr rpl_memchr
 #  endif
 _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
-                                  __attribute__ ((__pure__))
+                                  _GL_ATTRIBUTE_PURE
                                   _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
 # else
 #  if ! @HAVE_MEMCHR@
 _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
-                                  __attribute__ ((__pure__))
+                                  _GL_ATTRIBUTE_PURE
                                   _GL_ARG_NONNULL ((1)));
 #  endif
   /* On some systems, this function is defined as an overloaded function:
@@ -102,7 +104,8 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
 _GL_FUNCDECL_RPL (memmem, void *,
                   (void const *__haystack, size_t __haystack_len,
                    void const *__needle, size_t __needle_len)
-                  __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
+                  _GL_ATTRIBUTE_PURE
+                  _GL_ARG_NONNULL ((1, 3)));
 _GL_CXXALIAS_RPL (memmem, void *,
                   (void const *__haystack, size_t __haystack_len,
                    void const *__needle, size_t __needle_len));
@@ -111,7 +114,8 @@ _GL_CXXALIAS_RPL (memmem, void *,
 _GL_FUNCDECL_SYS (memmem, void *,
                   (void const *__haystack, size_t __haystack_len,
                    void const *__needle, size_t __needle_len)
-                  __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)));
+                  _GL_ATTRIBUTE_PURE
+                  _GL_ARG_NONNULL ((1, 3)));
 #  endif
 _GL_CXXALIAS_SYS (memmem, void *,
                   (void const *__haystack, size_t __haystack_len,
@@ -152,7 +156,7 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
 #if @GNULIB_MEMRCHR@
 # if ! @HAVE_DECL_MEMRCHR@
 _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
-                                   __attribute__ ((__pure__))
+                                   _GL_ATTRIBUTE_PURE
                                    _GL_ARG_NONNULL ((1)));
 # endif
   /* On some systems, this function is defined as an overloaded function:
@@ -182,7 +186,7 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
 #if @GNULIB_RAWMEMCHR@
 # if ! @HAVE_RAWMEMCHR@
 _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
-                                     __attribute__ ((__pure__))
+                                     _GL_ATTRIBUTE_PURE
                                      _GL_ARG_NONNULL ((1)));
 # endif
   /* On some systems, this function is defined as an overloaded function:
@@ -272,7 +276,7 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
 #if @GNULIB_STRCHRNUL@
 # if ! @HAVE_STRCHRNUL@
 _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
-                                     __attribute__ ((__pure__))
+                                     _GL_ATTRIBUTE_PURE
                                      _GL_ARG_NONNULL ((1)));
 # endif
   /* On some systems, this function is defined as an overloaded function:
@@ -378,13 +382,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
 #   define strnlen rpl_strnlen
 #  endif
 _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
-                                   __attribute__ ((__pure__))
+                                   _GL_ATTRIBUTE_PURE
                                    _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
 # else
 #  if ! @HAVE_DECL_STRNLEN@
 _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
-                                   __attribute__ ((__pure__))
+                                   _GL_ATTRIBUTE_PURE
                                    _GL_ARG_NONNULL ((1)));
 #  endif
 _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
@@ -414,7 +418,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
 #if @GNULIB_STRPBRK@
 # if ! @HAVE_STRPBRK@
 _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
-                                   __attribute__ ((__pure__))
+                                   _GL_ATTRIBUTE_PURE
                                    _GL_ARG_NONNULL ((1, 2)));
 # endif
   /* On some systems, this function is defined as an overloaded function:
@@ -514,7 +518,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - "
 #   define strstr rpl_strstr
 #  endif
 _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle)
-                                  __attribute__ ((__pure__))
+                                  _GL_ATTRIBUTE_PURE
                                   _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
 # else
@@ -556,14 +560,16 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
 #  endif
 _GL_FUNCDECL_RPL (strcasestr, char *,
                   (const char *haystack, const char *needle)
-                  __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
+                  _GL_ATTRIBUTE_PURE
+                  _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (strcasestr, char *,
                   (const char *haystack, const char *needle));
 # else
 #  if ! @HAVE_STRCASESTR@
 _GL_FUNCDECL_SYS (strcasestr, char *,
                   (const char *haystack, const char *needle)
-                  __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)));
+                  _GL_ATTRIBUTE_PURE
+                  _GL_ARG_NONNULL ((1, 2)));
 #  endif
   /* On some systems, this function is defined as an overloaded function:
        extern "C++" { const char * strcasestr (const char *, const char *); }