changeset 16130:376ca4146b05

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.
author Jim Meyering <meyering@redhat.com>
date Mon, 28 Nov 2011 10:24:04 +0100
parents 5595ced97d38
children 732c22001112
files ChangeLog lib/propername.c lib/propername.h
diffstat 3 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2011-11-28  Jim Meyering  <meyering@redhat.com>
 
+	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.
 
--- 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.  */
--- a/lib/propername.h
+++ b/lib/propername.h
@@ -89,7 +89,7 @@
 #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