From 331fd484374910cb99e0ace4b24d59be0ff16174 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 30 Jun 2010 02:19:54 +0200 Subject: [PATCH] string: Fix syntax error with g++ 2.96. (cherry picked from commit 7740412b04f93987e9e9c084c2dc86d5366db324) --- ChangeLog | 9 +++++++++ lib/string.in.h | 38 ++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f45cab51d..1d384642c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-06-29 Bruno Haible + + 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 . + 2010-06-28 Ian Beckwith unitypes: Fix bug introduced on 2010-05-18. diff --git a/lib/string.in.h b/lib/string.in.h index de446b47a..ca907b595 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -41,10 +41,12 @@ # 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 @@ -62,13 +64,13 @@ # 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 *); } -- 2.11.0