public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: preprocessor/7029: preprocessor should ignore #warning with -M
@ 2002-07-01 14:36 Zack Weinberg
0 siblings, 0 replies; 9+ messages in thread
From: Zack Weinberg @ 2002-07-01 14:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7029; it has been noted by GNATS.
From: Zack Weinberg <zack@codesourcery.com>
To: Neil Booth <neil@daikokuya.co.uk>
Cc: wolfgang.bangerth@iwr.uni-heidelberg.de, gcc-gnats@gcc.gnu.org,
gcc-bugs@gcc.gnu.org
Subject: Re: preprocessor/7029: preprocessor should ignore #warning with -M
Date: Mon, 1 Jul 2002 14:33:20 -0700
On Mon, Jul 01, 2002 at 10:20:29PM +0100, Neil Booth wrote:
> Zack Weinberg wrote:-
>
> > > Warnings are sent to stderr and the dpendency information isn't; so if
> > > you don't want the warnings you are free to pipe stderr to /dev/null.
> > > If you still wanted to retain errors but not warnings you can use -w,
> > > or check the compiler return code.
> > >
> > > So I disagree that there is any reason to change the existing behaviour,
> > > and want to close this PR. Do you agree, Zack?
> >
> > Well, I think it might be reasonable for -M switches that inhibit
> > compilation to imply -w. Presumably the user will get all the
> > warnings in due course as part of the real compilation.
>
> Fair enough; I'll create a patch.
Thanks.
zw
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: preprocessor/7029: preprocessor should ignore #warning with -M
@ 2002-07-02 15:35 neil
0 siblings, 0 replies; 9+ messages in thread
From: neil @ 2002-07-02 15:35 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, wolfgang.bangerth
Synopsis: preprocessor should ignore #warning with -M
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Tue Jul 2 15:34:59 2002
State-Changed-Why:
Fixed for 3.2.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7029
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: preprocessor/7029: preprocessor should ignore #warning with -M
@ 2002-07-01 22:56 Neil Booth
0 siblings, 0 replies; 9+ messages in thread
From: Neil Booth @ 2002-07-01 22:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7029; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.co.uk>
To: Zack Weinberg <zack@codesourcery.com>
Cc: wolfgang.bangerth@iwr.uni-heidelberg.de, gcc-gnats@gcc.gnu.org,
gcc-patches@gcc.gnu.org
Subject: Re: preprocessor/7029: preprocessor should ignore #warning with -M
Date: Tue, 2 Jul 2002 06:48:15 +0100
Zack Weinberg wrote:-
> On Mon, Jul 01, 2002 at 10:47:10PM +0100, Neil Booth wrote:
> > + /* If we're outputting dependencies then inhibit warnings, otherwise
> > + complain if other -M options have been given. */
> > + if (CPP_OPTION (pfile, print_deps))
> > + CPP_OPTION (pfile, inhibit_warnings) = 1;
>
> This will suppress warnings when -MD or -MF is in use, won't it? We
> still want them then (since we're proceeding to do the compilation,
> and the user will never see them otherwise).
Damn, yes, this area is a right minefield. The sad thing is that the
patch bootstrapped without regressions even though the move of
no_output suffers the same problem. We have poor coverage of -M
and friends still, despite Jakub's new testcases.
Neil.
* cppinit.c (cpp_handle_option): Suppress warnings with an
implicit "-w" for "-M" and "-MM".
doc:
* cppopts.texi: Update.
testsuite:
* gcc.dg/cpp/cmdlne-M.c: New test.
Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.242
diff -u -p -r1.242 cppinit.c
--- cppinit.c 19 Jun 2002 05:40:04 -0000 1.242
+++ cppinit.c 2 Jul 2002 05:50:59 -0000
@@ -1532,10 +1532,12 @@ cpp_handle_option (pfile, argc, argv)
or environment var dependency generation is used. */
CPP_OPTION (pfile, print_deps) = 2;
CPP_OPTION (pfile, no_output) = 1;
+ CPP_OPTION (pfile, inhibit_warnings) = 1;
break;
case OPT_MM:
CPP_OPTION (pfile, print_deps) = 1;
CPP_OPTION (pfile, no_output) = 1;
+ CPP_OPTION (pfile, inhibit_warnings) = 1;
break;
case OPT_MF:
CPP_OPTION (pfile, deps_file) = arg;
@@ -1794,14 +1796,13 @@ cpp_post_options (pfile)
if (CPP_OPTION (pfile, traditional))
CPP_OPTION (pfile, show_column) = 0;
- /* -dM makes no normal output. This is set here so that -dM -dD
- works as expected. */
+ /* -dM and dependencies suppress normal output; do it here so that
+ the last -d[MDN] switch overrides earlier ones. */
if (CPP_OPTION (pfile, dump_macros) == dump_only)
CPP_OPTION (pfile, no_output) = 1;
- /* Disable -dD, -dN and -dI if we should make no normal output
- (such as with -M). Allow -M -dM since some software relies on
- this. */
+ /* Disable -dD, -dN and -dI if normal output is suppressed. Allow
+ -dM since at least glibc relies on -M -dM to work. */
if (CPP_OPTION (pfile, no_output))
{
if (CPP_OPTION (pfile, dump_macros) != dump_only)
@@ -1809,17 +1810,16 @@ cpp_post_options (pfile)
CPP_OPTION (pfile, dump_includes) = 0;
}
- /* We need to do this after option processing and before
- cpp_start_read, as cppmain.c relies on the options->no_output to
- set its callbacks correctly before calling cpp_start_read. */
+ /* Intialize, and check environment variables for, dependency
+ output. */
init_dependency_output (pfile);
- /* After checking the environment variables, check if -M or -MM has
- not been specified, but other -M options have. */
- if (CPP_OPTION (pfile, print_deps) == 0 &&
- (CPP_OPTION (pfile, print_deps_missing_files)
- || CPP_OPTION (pfile, deps_file)
- || CPP_OPTION (pfile, deps_phony_targets)))
+ /* If we're not outputting dependencies, complain if other -M
+ options have been given. */
+ if (!CPP_OPTION (pfile, print_deps)
+ && (CPP_OPTION (pfile, print_deps_missing_files)
+ || CPP_OPTION (pfile, deps_file)
+ || CPP_OPTION (pfile, deps_phony_targets))
cpp_error (pfile, DL_ERROR,
"you must additionally specify either -M or -MM");
}
Index: testsuite/gcc.dg/cpp/cmdlne-M.c
===================================================================
RCS file: testsuite/gcc.dg/cpp/cmdlne-M.c
diff -N testsuite/gcc.dg/cpp/cmdlne-M.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/cpp/cmdlne-M.c 2 Jul 2002 05:50:59 -0000
@@ -0,0 +1,8 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-M" } */
+
+/* Test that dependency output suppresses warnings by implying -w. */
+
+#warning bogus /* { dg-bogus "warning" "warning not suppressed" } */
Index: doc/cppopts.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/cppopts.texi,v
retrieving revision 1.6
diff -u -p -r1.6 cppopts.texi
--- doc/cppopts.texi 8 May 2002 21:21:19 -0000 1.6
+++ doc/cppopts.texi 2 Jul 2002 05:50:59 -0000
@@ -178,7 +178,8 @@ rules you should explicitly specify the
@env{DEPENDENCIES_OUTPUT} (@pxref{Environment Variables}). Debug output
will still be sent to the regular output stream as normal.
-Passing @option{-M} to the driver implies @option{-E}.
+Passing @option{-M} to the driver implies @option{-E}, and suppresses
+warnings with an implicit @option{-w}.
@item -MM
@opindex MM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: preprocessor/7029: preprocessor should ignore #warning with -M
@ 2002-07-01 15:56 Zack Weinberg
0 siblings, 0 replies; 9+ messages in thread
From: Zack Weinberg @ 2002-07-01 15:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7029; it has been noted by GNATS.
From: Zack Weinberg <zack@codesourcery.com>
To: Neil Booth <neil@daikokuya.co.uk>
Cc: wolfgang.bangerth@iwr.uni-heidelberg.de, gcc-gnats@gcc.gnu.org,
gcc-patches@gcc.gnu.org
Subject: Re: preprocessor/7029: preprocessor should ignore #warning with -M
Date: Mon, 1 Jul 2002 15:49:09 -0700
On Mon, Jul 01, 2002 at 10:47:10PM +0100, Neil Booth wrote:
> + /* If we're outputting dependencies then inhibit warnings, otherwise
> + complain if other -M options have been given. */
> + if (CPP_OPTION (pfile, print_deps))
> + CPP_OPTION (pfile, inhibit_warnings) = 1;
This will suppress warnings when -MD or -MF is in use, won't it? We
still want them then (since we're proceeding to do the compilation,
and the user will never see them otherwise).
zw
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: preprocessor/7029: preprocessor should ignore #warning with -M
@ 2002-07-01 14:56 Neil Booth
0 siblings, 0 replies; 9+ messages in thread
From: Neil Booth @ 2002-07-01 14:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7029; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.co.uk>
To: Zack Weinberg <zack@codesourcery.com>
Cc: wolfgang.bangerth@iwr.uni-heidelberg.de, gcc-gnats@gcc.gnu.org,
gcc-patches@gcc.gnu.org
Subject: Re: preprocessor/7029: preprocessor should ignore #warning with -M
Date: Mon, 1 Jul 2002 22:47:10 +0100
Neil Booth wrote:-
> > Well, I think it might be reasonable for -M switches that inhibit
> > compilation to imply -w. Presumably the user will get all the
> > warnings in due course as part of the real compilation.
>
> Fair enough; I'll create a patch.
Here it is. I'll apply it after a successful bootstrap. I took
the opportunity to clarify some comments and move output
suppression to what I think is a better place than the option handler.
Neil.
* cppinit.c (cpp_handle_option): Move suppression of output
for -M and -MM to...
(cpp_post_options): ...here. If we're outputting dependencies,
suppress warnings with an implicit "-w".
doc:
* cppopts.texi: Update.
testsuite:
* gcc.dg/cpp/cmdlne-M.c: New test.
Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.242
diff -u -p -r1.242 cppinit.c
--- cppinit.c 19 Jun 2002 05:40:04 -0000 1.242
+++ cppinit.c 1 Jul 2002 21:44:46 -0000
@@ -1531,11 +1531,9 @@ cpp_handle_option (pfile, argc, argv)
depends on this. Preprocessed output occurs if -MD, -MMD
or environment var dependency generation is used. */
CPP_OPTION (pfile, print_deps) = 2;
- CPP_OPTION (pfile, no_output) = 1;
break;
case OPT_MM:
CPP_OPTION (pfile, print_deps) = 1;
- CPP_OPTION (pfile, no_output) = 1;
break;
case OPT_MF:
CPP_OPTION (pfile, deps_file) = arg;
@@ -1794,14 +1792,14 @@ cpp_post_options (pfile)
if (CPP_OPTION (pfile, traditional))
CPP_OPTION (pfile, show_column) = 0;
- /* -dM makes no normal output. This is set here so that -dM -dD
- works as expected. */
- if (CPP_OPTION (pfile, dump_macros) == dump_only)
+ /* -dM and dependencies suppress normal output; do it here so that
+ the last -d[MDN] switch overrides earlier ones. */
+ if (CPP_OPTION (pfile, dump_macros) == dump_only
+ || CPP_OPTION (pfile, print_deps))
CPP_OPTION (pfile, no_output) = 1;
- /* Disable -dD, -dN and -dI if we should make no normal output
- (such as with -M). Allow -M -dM since some software relies on
- this. */
+ /* Disable -dD, -dN and -dI if normal output is suppressed. Allow
+ -dM since at least glibc relies on -M -dM to work. */
if (CPP_OPTION (pfile, no_output))
{
if (CPP_OPTION (pfile, dump_macros) != dump_only)
@@ -1809,17 +1807,17 @@ cpp_post_options (pfile)
CPP_OPTION (pfile, dump_includes) = 0;
}
- /* We need to do this after option processing and before
- cpp_start_read, as cppmain.c relies on the options->no_output to
- set its callbacks correctly before calling cpp_start_read. */
+ /* Intialize, and check environment variables for, dependency
+ output. */
init_dependency_output (pfile);
- /* After checking the environment variables, check if -M or -MM has
- not been specified, but other -M options have. */
- if (CPP_OPTION (pfile, print_deps) == 0 &&
- (CPP_OPTION (pfile, print_deps_missing_files)
- || CPP_OPTION (pfile, deps_file)
- || CPP_OPTION (pfile, deps_phony_targets)))
+ /* If we're outputting dependencies then inhibit warnings, otherwise
+ complain if other -M options have been given. */
+ if (CPP_OPTION (pfile, print_deps))
+ CPP_OPTION (pfile, inhibit_warnings) = 1;
+ else if (CPP_OPTION (pfile, print_deps_missing_files)
+ || CPP_OPTION (pfile, deps_file)
+ || CPP_OPTION (pfile, deps_phony_targets))
cpp_error (pfile, DL_ERROR,
"you must additionally specify either -M or -MM");
}
Index: testsuite/gcc.dg/cpp/cmdlne-M.c
===================================================================
RCS file: testsuite/gcc.dg/cpp/cmdlne-M.c
diff -N testsuite/gcc.dg/cpp/cmdlne-M.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/cpp/cmdlne-M.c 1 Jul 2002 21:44:46 -0000
@@ -0,0 +1,8 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-M" } */
+
+/* Test that dependency output suppresses warnings by implying -w. */
+
+#warning bogus /* { dg-bogus "warning" "warning not suppressed" } */
Index: doc/cppopts.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/cppopts.texi,v
retrieving revision 1.6
diff -u -p -r1.6 cppopts.texi
--- doc/cppopts.texi 8 May 2002 21:21:19 -0000 1.6
+++ doc/cppopts.texi 1 Jul 2002 21:44:46 -0000
@@ -178,7 +178,8 @@ rules you should explicitly specify the
@env{DEPENDENCIES_OUTPUT} (@pxref{Environment Variables}). Debug output
will still be sent to the regular output stream as normal.
-Passing @option{-M} to the driver implies @option{-E}.
+Passing @option{-M} to the driver implies @option{-E}, and suppresses
+warnings with an implicit @option{-w}.
@item -MM
@opindex MM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: preprocessor/7029: preprocessor should ignore #warning with -M
@ 2002-07-01 14:26 Neil Booth
0 siblings, 0 replies; 9+ messages in thread
From: Neil Booth @ 2002-07-01 14:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7029; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.co.uk>
To: Zack Weinberg <zack@codesourcery.com>
Cc: wolfgang.bangerth@iwr.uni-heidelberg.de, gcc-gnats@gcc.gnu.org,
gcc-bugs@gcc.gnu.org
Subject: Re: preprocessor/7029: preprocessor should ignore #warning with -M
Date: Mon, 1 Jul 2002 22:20:29 +0100
Zack Weinberg wrote:-
> > Warnings are sent to stderr and the dpendency information isn't; so if
> > you don't want the warnings you are free to pipe stderr to /dev/null.
> > If you still wanted to retain errors but not warnings you can use -w,
> > or check the compiler return code.
> >
> > So I disagree that there is any reason to change the existing behaviour,
> > and want to close this PR. Do you agree, Zack?
>
> Well, I think it might be reasonable for -M switches that inhibit
> compilation to imply -w. Presumably the user will get all the
> warnings in due course as part of the real compilation.
Fair enough; I'll create a patch.
Neil.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: preprocessor/7029: preprocessor should ignore #warning with -M
@ 2002-07-01 14:26 Zack Weinberg
0 siblings, 0 replies; 9+ messages in thread
From: Zack Weinberg @ 2002-07-01 14:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7029; it has been noted by GNATS.
From: Zack Weinberg <zack@codesourcery.com>
To: Neil Booth <neil@daikokuya.co.uk>
Cc: wolfgang.bangerth@iwr.uni-heidelberg.de, gcc-gnats@gcc.gnu.org,
gcc-bugs@gcc.gnu.org
Subject: Re: preprocessor/7029: preprocessor should ignore #warning with -M
Date: Mon, 1 Jul 2002 14:20:38 -0700
On Mon, Jul 01, 2002 at 10:04:49PM +0100, Neil Booth wrote:
> > IMHO, warnings generated by #warning may be omitted when not
> > actually compiling code, for example when using -M to
> > generate dependency lists. They seem inappropriate for this
> > task.
> > >How-To-Repeat:
> > program> echo "#warning Warn about something" > x.cc
> > program> gcc -M x.cc
> > x.cc:1:2: warning: #warning Warn about something
> > x.o: x.cc
>
> Warnings are sent to stderr and the dpendency information isn't; so if
> you don't want the warnings you are free to pipe stderr to /dev/null.
> If you still wanted to retain errors but not warnings you can use -w,
> or check the compiler return code.
>
> So I disagree that there is any reason to change the existing behaviour,
> and want to close this PR. Do you agree, Zack?
Well, I think it might be reasonable for -M switches that inhibit
compilation to imply -w. Presumably the user will get all the
warnings in due course as part of the real compilation.
zw
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: preprocessor/7029: preprocessor should ignore #warning with -M
@ 2002-07-01 14:16 Neil Booth
0 siblings, 0 replies; 9+ messages in thread
From: Neil Booth @ 2002-07-01 14:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7029; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.co.uk>
To: wolfgang.bangerth@iwr.uni-heidelberg.de,
Zack Weinberg <zack@codesourcery.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org
Subject: Re: preprocessor/7029: preprocessor should ignore #warning with -M
Date: Mon, 1 Jul 2002 22:04:49 +0100
> IMHO, warnings generated by #warning may be omitted when not
> actually compiling code, for example when using -M to
> generate dependency lists. They seem inappropriate for this
> task.
> >How-To-Repeat:
> program> echo "#warning Warn about something" > x.cc
> program> gcc -M x.cc
> x.cc:1:2: warning: #warning Warn about something
> x.o: x.cc
Warnings are sent to stderr and the dpendency information isn't; so if
you don't want the warnings you are free to pipe stderr to /dev/null.
If you still wanted to retain errors but not warnings you can use -w,
or check the compiler return code.
So I disagree that there is any reason to change the existing behaviour,
and want to close this PR. Do you agree, Zack?
Neil.
^ permalink raw reply [flat|nested] 9+ messages in thread
* preprocessor/7029: preprocessor should ignore #warning with -M
@ 2002-06-14 6:06 wolfgang.bangerth
0 siblings, 0 replies; 9+ messages in thread
From: wolfgang.bangerth @ 2002-06-14 6:06 UTC (permalink / raw)
To: gcc-gnats
>Number: 7029
>Category: preprocessor
>Synopsis: preprocessor should ignore #warning with -M
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Fri Jun 14 04:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Wolfgang Bangerth
>Release: unknown-1.0
>Organization:
>Environment:
all
>Description:
IMHO, warnings generated by #warning may be omitted when not
actually compiling code, for example when using -M to
generate dependency lists. They seem inappropriate for this
task.
>How-To-Repeat:
program> echo "#warning Warn about something" > x.cc
program> gcc -M x.cc
x.cc:1:2: warning: #warning Warn about something
x.o: x.cc
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2002-07-02 22:35 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-01 14:36 preprocessor/7029: preprocessor should ignore #warning with -M Zack Weinberg
-- strict thread matches above, loose matches on Subject: below --
2002-07-02 15:35 neil
2002-07-01 22:56 Neil Booth
2002-07-01 15:56 Zack Weinberg
2002-07-01 14:56 Neil Booth
2002-07-01 14:26 Neil Booth
2002-07-01 14:26 Zack Weinberg
2002-07-01 14:16 Neil Booth
2002-06-14 6:06 wolfgang.bangerth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).