This is the mail archive of the gcc-patches@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]

Patch to CPP_PEDANTIC


I assert that we should never be pedantic about code from system headers.
Any objections?

2000-03-02  Jason Merrill  <jason@casey.cygnus.com>

	* cpplib.h (CPP_PEDANTIC): Only true if system_header_p is not set
	for the buffer.
	(SET_CPP_PEDANTIC): New macro.
	* cpplib.c (do_include): Don't bother checking system_header_p.
	(do_warning, do_ident, do_assert, do_unassert): Likewise.

Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplib.c,v
retrieving revision 1.122
diff -c -p -r1.122 cpplib.c
*** cpplib.c	2000/03/02 20:14:32	1.122
--- cpplib.c	2000/03/03 00:01:38
*************** do_include (pfile, keyword)
*** 1068,1074 ****
  
    int fd;
  
!   if (CPP_PEDANTIC (pfile) && !CPP_BUFFER (pfile)->system_header_p)
      {
        if (importing)
  	cpp_pedwarn (pfile, "ANSI C does not allow `#import'");
--- 1068,1074 ----
  
    int fd;
  
!   if (CPP_PEDANTIC (pfile))
      {
        if (importing)
  	cpp_pedwarn (pfile, "ANSI C does not allow `#import'");
*************** do_warning (pfile, keyword)
*** 1555,1561 ****
    skip_rest_of_line (pfile);
    limit = CPP_BUFFER (pfile)->cur;
  
!   if (CPP_PEDANTIC (pfile) && !CPP_BUFFER (pfile)->system_header_p)
      cpp_pedwarn (pfile, "ANSI C does not allow `#warning'");
  
    cpp_warning (pfile, "#warning %.*s", (int)(limit - text), text);
--- 1555,1561 ----
    skip_rest_of_line (pfile);
    limit = CPP_BUFFER (pfile)->cur;
  
!   if (CPP_PEDANTIC (pfile))
      cpp_pedwarn (pfile, "ANSI C does not allow `#warning'");
  
    cpp_warning (pfile, "#warning %.*s", (int)(limit - text), text);
*************** do_ident (pfile, keyword)
*** 1572,1578 ****
    long old_written = CPP_WRITTEN (pfile);
  
    /* Allow #ident in system headers, since that's not user's fault.  */
!   if (CPP_PEDANTIC (pfile) && !CPP_BUFFER (pfile)->system_header_p)
      cpp_pedwarn (pfile, "ANSI C does not allow `#ident'");
  
    CPP_PUTS (pfile, "#ident ", 7);
--- 1572,1578 ----
    long old_written = CPP_WRITTEN (pfile);
  
    /* Allow #ident in system headers, since that's not user's fault.  */
!   if (CPP_PEDANTIC (pfile))
      cpp_pedwarn (pfile, "ANSI C does not allow `#ident'");
  
    CPP_PUTS (pfile, "#ident ", 7);
*************** validate_else (pfile, directive)
*** 2292,2298 ****
       cpp_reader *pfile;
       const char *directive;
  {
!   if (! CPP_PEDANTIC (pfile) || CPP_BUFFER (pfile)->system_header_p)
      return;
  
    cpp_skip_hspace (pfile);
--- 2292,2298 ----
       cpp_reader *pfile;
       const char *directive;
  {
!   if (! CPP_PEDANTIC (pfile))
      return;
  
    cpp_skip_hspace (pfile);
*************** do_assert (pfile, keyword)
*** 3060,3067 ****
    HASHNODE *base, *this;
    int baselen, thislen;
  
!   if (CPP_PEDANTIC (pfile) && CPP_OPTIONS (pfile)->done_initializing
!       && !CPP_BUFFER (pfile)->system_header_p)
      cpp_pedwarn (pfile, "ANSI C does not allow `#assert'");
  
    cpp_skip_hspace (pfile);
--- 3060,3066 ----
    HASHNODE *base, *this;
    int baselen, thislen;
  
!   if (CPP_PEDANTIC (pfile) && CPP_OPTIONS (pfile)->done_initializing)
      cpp_pedwarn (pfile, "ANSI C does not allow `#assert'");
  
    cpp_skip_hspace (pfile);
*************** do_unassert (pfile, keyword)
*** 3125,3132 ****
    long baselen, thislen;
    HASHNODE *base, *this, *next;
    
!   if (CPP_PEDANTIC (pfile) && CPP_OPTIONS (pfile)->done_initializing
!       && !CPP_BUFFER (pfile)->system_header_p)
      cpp_pedwarn (pfile, "ANSI C does not allow `#unassert'");
  
    cpp_skip_hspace (pfile);
--- 3124,3130 ----
    long baselen, thislen;
    HASHNODE *base, *this, *next;
    
!   if (CPP_PEDANTIC (pfile) && CPP_OPTIONS (pfile)->done_initializing)
      cpp_pedwarn (pfile, "ANSI C does not allow `#unassert'");
  
    cpp_skip_hspace (pfile);
Index: cpplib.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplib.h,v
retrieving revision 1.60
diff -c -p -r1.60 cpplib.h
*** cpplib.h	2000/03/02 20:14:32	1.60
--- cpplib.h	2000/03/03 00:01:39
*************** struct cpp_options {
*** 508,516 ****
  #define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional)
  #define CPP_WARN_UNDEF(PFILE) (CPP_OPTIONS(PFILE)->warn_undef)
  #define CPP_C89(PFILE) (CPP_OPTIONS(PFILE)->c89)
- #define CPP_PEDANTIC(PFILE) (CPP_OPTIONS (PFILE)->pedantic)
  #define CPP_PREPROCESSED(PFILE) (CPP_OPTIONS (PFILE)->preprocessed)
  #define CPP_PRINT_DEPS(PFILE) (CPP_OPTIONS (PFILE)->print_deps)
  
  /* List of directories to look for include files in. */
  struct file_name_list
--- 508,520 ----
  #define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional)
  #define CPP_WARN_UNDEF(PFILE) (CPP_OPTIONS(PFILE)->warn_undef)
  #define CPP_C89(PFILE) (CPP_OPTIONS(PFILE)->c89)
  #define CPP_PREPROCESSED(PFILE) (CPP_OPTIONS (PFILE)->preprocessed)
  #define CPP_PRINT_DEPS(PFILE) (CPP_OPTIONS (PFILE)->print_deps)
+ 
+ #define CPP_PEDANTIC(PFILE) \
+   (CPP_OPTIONS (PFILE)->pedantic && !CPP_BUFFER (pfile)->system_header_p)
+ 
+ #define SET_CPP_PEDANTIC(PFILE) (CPP_OPTIONS (PFILE)->pedantic = 1)
  
  /* List of directories to look for include files in. */
  struct file_name_list

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