This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Desire gcc option to skip warnings in standard headers


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.

Comments, anybody? Is this the right way to do it?

--
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/toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.79
diff -p -r1.79 toplev.c
*** toplev.c	1998/06/27 15:51:49	1.79
--- toplev.c	1998/06/29 12:17:47
*************** int warn_inline;
*** 985,990 ****
--- 985,994 ----
  
  int warn_aggregate_return;
  
+ /* Ignore warnings generated in system headers */
+ 
+ int warn_system_headers;
+ 
  /* Likewise for -W.  */
  
  struct { char *string; int *variable; int on_value;} W_options[] =
*************** struct { char *string; int *variable; in
*** 996,1002 ****
    {"aggregate-return", &warn_aggregate_return, 1},
    {"cast-align", &warn_cast_align, 1},
    {"uninitialized", &warn_uninitialized, 1},
!   {"inline", &warn_inline, 1}
  };
  
  /* Output files for assembler code (real compiler output)
--- 1000,1007 ----
    {"aggregate-return", &warn_aggregate_return, 1},
    {"cast-align", &warn_cast_align, 1},
    {"uninitialized", &warn_uninitialized, 1},
!   {"inline", &warn_inline, 1},
!   {"system-headers", &warn_system_headers, 1}
  };
  
  /* Output files for assembler code (real compiler output)
*************** int
*** 1121,1127 ****
  count_error (warningp)
       int warningp;
  {
!   if (warningp && inhibit_warnings)
      return 0;
  
    if (warningp && !warnings_are_errors)
--- 1126,1133 ----
  count_error (warningp)
       int warningp;
  {
!   if (warningp && (inhibit_warnings
!                    || (in_system_header && !warn_system_headers)))
      return 0;
  
    if (warningp && !warnings_are_errors)
Index: gcc/flags.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/flags.h,v
retrieving revision 1.16
diff -p -r1.16 flags.h
*** flags.h	1998/06/25 15:14:16	1.16
--- flags.h	1998/06/29 12:17:47
*************** extern unsigned larger_than_size;
*** 137,142 ****
--- 137,146 ----
  
  extern int warn_aggregate_return;
  
+ /* Ignore warnings generated in system headers */
+ 
+ extern int warn_system_headers;
+ 
  /* Nonzero if generating code to do profiling.  */
  
  extern int profile_flag;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]