cpplib: Honour #warning in system headers

Neil Booth neil@daikokuya.demon.co.uk
Sat Apr 7 03:25:00 GMT 2001


And remove a <stdin> duplicate in cpperror.c, now that we
do it in cpplib.c.

Is this OK for mainline and branch with the current state of
libstdc++ Benjamin?

Neil.

	* cpperror.c (print_location): Don't special case <stdin>.
	(_cpp_begin_message): Handle WARNING_SYSHDR the same as
	WARNING, but we don't check if we're in system headers.
	* cpplib.h (enum error_type): WARNING_SYSHDR: New.
	* cpplib.c (do_warning): Warn in system headers.

Index: cpperror.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpperror.c,v
retrieving revision 1.45
diff -u -p -r1.45 cpperror.c
--- cpperror.c	2001/01/23 19:20:14	1.45
+++ cpperror.c	2001/04/07 10:15:47
@@ -124,8 +124,6 @@ print_location (pfile, filename, pos)
 
       if (filename == 0)
 	filename = buffer->nominal_fname;
-      if (*filename == '\0')
-	filename = _("<stdin>");
 
       if (line == 0)
 	fprintf (stderr, "%s: ", filename);
@@ -159,6 +157,7 @@ _cpp_begin_message (pfile, code, file, p
       if (CPP_IN_SYSTEM_HEADER (pfile)
 	  && ! CPP_OPTION (pfile, warn_system_headers))
 	return 0;
+    case WARNING_SYSHDR:
       if (CPP_OPTION (pfile, warnings_are_errors)
 	  || (code == PEDWARN && CPP_OPTION (pfile, pedantic_errors)))
 	{
Index: cpphash.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpphash.h,v
retrieving revision 1.102
diff -u -p -r1.102 cpphash.h
--- cpphash.h	2001/03/15 07:54:54	1.102
+++ cpphash.h	2001/04/07 10:15:57
@@ -389,7 +389,7 @@ extern unsigned char _cpp_trigraph_map[U
 #define HASHSTEP(r, c) ((r) * 67 + (c - 113));
 
 /* In cpperror.c  */
-enum error_type { WARNING = 0, PEDWARN, ERROR, FATAL, ICE };
+enum error_type { WARNING = 0, WARNING_SYSHDR, PEDWARN, ERROR, FATAL, ICE };
 extern int _cpp_begin_message PARAMS ((cpp_reader *, enum error_type,
 				       const char *, const cpp_lexer_pos *));
 
Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.247
diff -u -p -r1.247 cpplib.c
--- cpplib.c	2001/04/06 21:43:53	1.247
+++ cpplib.c	2001/04/07 10:16:06
@@ -874,7 +874,8 @@ static void
 do_warning (pfile)
      cpp_reader *pfile;
 {
-  do_diagnostic (pfile, WARNING, 1);
+  /* We want #warning diagnostics to be emitted in system headers too.  */
+  do_diagnostic (pfile, WARNING_SYSHDR, 1);
 }
 
 /* Report program identification.  */



More information about the Gcc-patches mailing list