bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH 1/2] propername: mark one more function as const


From: Jim Meyering
Subject: [PATCH 1/2] propername: mark one more function as const
Date: Mon, 28 Nov 2011 10:28:13 +0100

I noticed that I'd missed a function, proper_name,
marked it as _GL_ATTRIBUTE_CONST, and then realized that
it must not be marked with that attribute, since not only
is it not "pure", but it is not "const" either.

>From b6656e88f137483b7407053679870618af180de7 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 28 Nov 2011 09:39:34 +0100
Subject: [PATCH 1/2] propername: mark one more function as const

* lib/propername.h (proper_name): Mark as _GL_ATTRIBUTE_CONST.
---
 ChangeLog        |    5 +++++
 lib/propername.h |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ba43f79..fe8f9d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-28  Jim Meyering  <address@hidden>
+
+       propername: mark one more function as const
+       * lib/propername.h (proper_name): Mark as _GL_ATTRIBUTE_CONST.
+
 2011-11-27  Jim Meyering  <address@hidden>

        mark functions with const and pure attributes
diff --git a/lib/propername.h b/lib/propername.h
index a4eac01..0141532 100644
--- a/lib/propername.h
+++ b/lib/propername.h
@@ -89,7 +89,7 @@ extern "C" {
 #endif

 /* Return the localization of NAME.  NAME is written in ASCII.  */
-extern const char * proper_name (const char *name) /* NOT PURE */;
+extern const char * proper_name (const char *name) _GL_ATTRIBUTE_CONST;

 /* Return the localization of a name whose original writing is not ASCII.
    NAME_UTF8 is the real name, written in UTF-8 with octal or hexadecimal
--
1.7.8.rc3.31.g017d1


>From 69f517e5975418e7b2c5033f8f60191919f44b9d Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 28 Nov 2011 10:24:04 +0100
Subject: [PATCH 2/2] propername: do not mark proper_name with the const
 attribute

* lib/propername.h (proper_name): Do *not* mark as _GL_ATTRIBUTE_CONST,
since it examines data pointed to by its parameter.
* lib/propername.c (proper_name): Instead, add a pragma to suppress
the suggestion from -Wsuggest-attribute=const.
---
 ChangeLog        |    6 ++++++
 lib/propername.c |    6 ++++++
 lib/propername.h |    2 +-
 3 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fe8f9d1..28fbe90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2011-11-28  Jim Meyering  <address@hidden>

+       propername: do not mark proper_name with the const attribute
+       * lib/propername.h (proper_name): Do *not* mark as _GL_ATTRIBUTE_CONST,
+       since it examines data pointed to by its parameter.
+       * lib/propername.c (proper_name): Instead, add a pragma to suppress
+       the suggestion from -Wsuggest-attribute=const.
+
        propername: mark one more function as const
        * lib/propername.h (proper_name): Mark as _GL_ATTRIBUTE_CONST.

diff --git a/lib/propername.c b/lib/propername.c
index b74923d..346c310 100644
--- a/lib/propername.c
+++ b/lib/propername.c
@@ -15,6 +15,12 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

+/* Without this pragma, gcc 4.7.0 20111124 mistakenly suggests that
+   the proper_name function might be candidate for attribute 'const'  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
+#endif
+
 #include <config.h>

 /* Specification.  */
diff --git a/lib/propername.h b/lib/propername.h
index 0141532..997c57b 100644
--- a/lib/propername.h
+++ b/lib/propername.h
@@ -89,7 +89,7 @@ extern "C" {
 #endif

 /* Return the localization of NAME.  NAME is written in ASCII.  */
-extern const char * proper_name (const char *name) _GL_ATTRIBUTE_CONST;
+extern const char * proper_name (const char *name) /* NOT attribute const */;

 /* Return the localization of a name whose original writing is not ASCII.
    NAME_UTF8 is the real name, written in UTF-8 with octal or hexadecimal
--
1.7.8.rc3.31.g017d1



reply via email to

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