This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 1/3] colorize: use isatty module
- From: Jim Meyering <jim at meyering dot net>
- To: Paolo Bonzini <bonzini at gnu dot org>
- Cc: bug-grep at gnu dot org, gcc at gnu dot org, Jan Hubicka <jh at suse dot cz>
- Date: Tue, 03 Jan 2012 10:27:43 +0100
- Subject: Re: [PATCH 1/3] colorize: use isatty module
- References: <1325579310-11721-1-git-send-email-bonzini@gnu.org> <1325579310-11721-2-git-send-email-bonzini@gnu.org> <874nwdp3x7.fsf@rho.meyering.net> <4F02C705.8000302@gnu.org>
Paolo Bonzini wrote:
> On 01/03/2012 09:48 AM, Jim Meyering wrote:
>> Paolo Bonzini wrote:
>>
>>> * bootstrap.conf: Add isatty module.
>>> * gnulib: Update to latest.
>>> * lib/colorize.h: Remove argument from should_colorize.
>>> * lib/ms/colorize.h: Likewise.
>>> * lib/colorize-impl.c: Factor isatty call out of here...
>>> * lib/ms/colorize-impl.c: ... and here...
>>> * src/main.c: ... into here.
>>
>> Hi Paolo,
>> At least with gcc-4.7.0 20120102, a warning-enabled build now fails like this:
>>
>> colorize.c: In function 'init_colorize':
>> colorize.c:37:6: error: function might be candidate for attribute
>> const' [-Werror=suggest-attribute=const]
>> cc1: all warnings being treated as errors
>
> Thanks, my GCC is indeed older.
>
> Perhaps GCC should be changed to avoid the warning on functions
> returning void. If a void function can be const, it pretty much has
> to be empty, and so it is quite likely a placeholder for something
> that is not const.
To address grep's immediate problem -- I require use of
--enable-gcc-warnings and want to continue using the newer gcc --
I have applied this:
>From 082f0d1a771a2febcc14ffce13f44ed7c4553ad4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Tue, 3 Jan 2012 10:25:37 +0100
Subject: [PATCH] build: avoid build failure with --enable-gcc-warnings and
recent gcc
* lib/colorize-posix.c: Disable -Wsuggest-attribute=const, to avoid
warning about this empty init_colorize function.
---
lib/colorize-posix.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/lib/colorize-posix.c b/lib/colorize-posix.c
index 37bc640..116bbb2 100644
--- a/lib/colorize-posix.c
+++ b/lib/colorize-posix.c
@@ -16,6 +16,12 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
+/* Without this pragma, gcc 4.7.0 20120102 suggests that the
+ init_colorize function might be candidate for attribute 'const' */
+#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
+#endif
+
#include <config.h>
#include "colorize.h"
--
1.7.8.1.391.g2c2ad