This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Desire gcc option to skip warnings in standard headers
- To: egcs at cygnus dot com, egcs-patches at cygnus dot com
- Subject: Re: Desire gcc option to skip warnings in standard headers
- From: Branko Cibej <branko dot cibej at hermes dot si>
- Date: Mon, 29 Jun 1998 15:34:12 +0200
- Organization: HERMES SoftLab
- References: <9806261352.AA18188@ipl.rpi.edu> <35978752.88CC4049@hermes.si>
Branko Cibej wrote:
> Frederick W. Wheeler wrote:
>
> > It would be very convenient for me to have a gcc command-line option
> > or #pragma to prevent the printing of warnings in the standard
> > headers. Warnings could begin to be issued at the first line that is
> > not #include <something.h>. It seems to me that this would be
> > relatively easy to implement.
>
> Here's a simple patch that inhibits warnings generated in system headers
> unless '-Wsystem-headers' is specified. It doesn't attempt to handle
> warnings generated by cccp or cpplib yet.
Here's another patch, this one handles cccp.
> Comments, anybody? Is this the right way to do it?
(Yes, yes, cut-and-paste programming and no changelog entries, but I'm just
playing around for the moment).
--
Branko Cibej <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
phone: (++386 61) 186 53 49 fax: (++386 61) 186 52 70
Index: gcc/cccp.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cccp.c,v
retrieving revision 1.28
diff -p -r1.28 cccp.c
*** cccp.c 1998/06/19 01:34:11 1.28
--- cccp.c 1998/06/29 13:30:15
*************** static int pedantic_errors;
*** 270,275 ****
--- 270,279 ----
static int inhibit_warnings = 0;
+ /* Ignore warnings generated in system headers */
+
+ static int warn_system_headers = 0;
+
/* Nonzero means warn if slash-star appears in a slash-star comment,
or if newline-backslash appears in a slash-slash comment. */
*************** main (argc, argv)
*** 1461,1466 ****
--- 1465,1474 ----
warn_trigraphs = 1;
warn_comments = 1;
}
+ else if (!strcmp (argv[i], "-Wsystem-headers"))
+ warn_system_headers = 1;
+ else if (!strcmp (argv[i], "-Wno-system-headers"))
+ warn_system_headers = 0;
break;
case 'M':
*************** vwarning (msg, args)
*** 9003,9009 ****
int i;
FILE_BUF *ip = NULL;
! if (inhibit_warnings)
return;
if (warnings_are_errors)
--- 9011,9018 ----
int i;
FILE_BUF *ip = NULL;
! if (inhibit_warnings
! || (instack[indepth].system_header_p && !warn_system_headers))
return;
if (warnings_are_errors)
*************** vwarning_with_line (line, msg, args)
*** 9101,9107 ****
int i;
FILE_BUF *ip = NULL;
! if (inhibit_warnings)
return;
if (warnings_are_errors)
--- 9110,9117 ----
int i;
FILE_BUF *ip = NULL;
! if (inhibit_warnings
! || (instack[indepth].system_header_p && !warn_system_headers))
return;
if (warnings_are_errors)
*************** pedwarn_with_file_and_line VPROTO ((char
*** 9185,9191 ****
#endif
va_list args;
! if (!pedantic_errors && inhibit_warnings)
return;
if (file) {
eprint_string (file, file_len);
--- 9195,9203 ----
#endif
va_list args;
! if (!pedantic_errors
! && (inhibit_warnings
! || (instack[indepth].system_header_p && !warn_system_headers)))
return;
if (file) {
eprint_string (file, file_len);