[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] mark functions with const and pure attributes
From: |
Bruno Haible |
Subject: |
Re: [PATCH] mark functions with const and pure attributes |
Date: |
Sun, 27 Nov 2011 22:37:02 +0100 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
Hi Jim,
> --- a/lib/quotearg.c
> +++ b/lib/quotearg.c
> @@ -17,6 +17,11 @@
>
> /* Written by Paul Eggert <address@hidden> */
>
> +/* Without this pragma, gcc 4.7.0 20111124 mistakenly suggests that
> + the quoting_options_from_style function might be candidate for
> + attribute 'pure' */
> +# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
> +
> #include <config.h>
>
> #include "quotearg.h"
This pragma line should be enclosed in
#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
#endif
like it is done in
lib/anytostr.c
lib/poll.c
tests/test-intprops.c
tests/test-nl_langinfo.c
Otherwise (most likely) earlier versions of GCC will warn about an unsupported
pragma.
> --- a/lib/uniwidth.in.h
> +++ b/lib/uniwidth.in.h
> @@ -38,7 +38,7 @@ extern "C" {
>
> /* Determine number of column positions required for UC. */
> extern int
> - uc_width (ucs4_t uc, const char *encoding);
> + uc_width (ucs4_t uc, const char *encoding) _GL_ATTRIBUTE_PURE;
>
> /* Determine number of column positions required for first N units
> (or fewer if S ends before this) in S. */
This header file is installed as a public header file by libunistring.
It cannot presuppose the macro definitions of gnulib-common.m4. Therefore
here one needs to write
extern int
uc_width (ucs4_t uc, const char *encoding)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute__ ((__pure__))
#endif
;
Bruno
--
In memoriam George Moscone <http://en.wikipedia.org/wiki/George_Moscone>