diff libcpp/errors.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line diff
--- a/libcpp/errors.c	Fri Oct 27 22:46:09 2017 +0900
+++ b/libcpp/errors.c	Thu Oct 25 07:37:49 2018 +0900
@@ -1,5 +1,5 @@
 /* Default error handlers for CPP Library.
-   Copyright (C) 1986-2017 Free Software Foundation, Inc.
+   Copyright (C) 1986-2018 Free Software Foundation, Inc.
    Written by Per Bothner, 1994.
    Based on CCCP program by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -31,33 +31,15 @@
 
 ATTRIBUTE_FPTR_PRINTF(5,0)
 static bool
-cpp_diagnostic_at_richloc (cpp_reader * pfile, int level, int reason,
-			   rich_location *richloc,
-			   const char *msgid, va_list *ap)
-{
-  bool ret;
-
-  if (!pfile->cb.error)
-    abort ();
-  ret = pfile->cb.error (pfile, level, reason, richloc, _(msgid), ap);
-
-  return ret;
-}
-
-/* Print a diagnostic at the given location.  */
-
-ATTRIBUTE_FPTR_PRINTF(5,0)
-static bool
-cpp_diagnostic_at (cpp_reader * pfile, int level, int reason,
-		   source_location src_loc,
+cpp_diagnostic_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
+		   enum cpp_warning_reason reason, rich_location *richloc,
 		   const char *msgid, va_list *ap)
 {
   bool ret;
 
-  if (!pfile->cb.error)
+  if (!pfile->cb.diagnostic)
     abort ();
-  rich_location richloc (pfile->line_table, src_loc);
-  ret = pfile->cb.error (pfile, level, reason, &richloc, _(msgid), ap);
+  ret = pfile->cb.diagnostic (pfile, level, reason, richloc, _(msgid), ap);
 
   return ret;
 }
@@ -66,8 +48,9 @@
 
 ATTRIBUTE_FPTR_PRINTF(4,0)
 static bool
-cpp_diagnostic (cpp_reader * pfile, int level, int reason,
-                const char *msgid, va_list *ap)
+cpp_diagnostic (cpp_reader * pfile, enum cpp_diagnostic_level level,
+		enum cpp_warning_reason reason,
+		const char *msgid, va_list *ap)
 {
   source_location src_loc;
 
@@ -88,13 +71,15 @@
     {
       src_loc = pfile->cur_token[-1].src_loc;
     }
-  return cpp_diagnostic_at (pfile, level, reason, src_loc, msgid, ap);
+  rich_location richloc (pfile->line_table, src_loc);
+  return cpp_diagnostic_at (pfile, level, reason, &richloc, msgid, ap);
 }
 
 /* Print a warning or error, depending on the value of LEVEL.  */
 
 bool
-cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
+cpp_error (cpp_reader * pfile, enum cpp_diagnostic_level level,
+	   const char *msgid, ...)
 {
   va_list ap;
   bool ret;
@@ -110,7 +95,8 @@
 /* Print a warning.  The warning reason may be given in REASON.  */
 
 bool
-cpp_warning (cpp_reader * pfile, int reason, const char *msgid, ...)
+cpp_warning (cpp_reader * pfile, enum cpp_warning_reason reason,
+	     const char *msgid, ...)
 {
   va_list ap;
   bool ret;
@@ -126,7 +112,8 @@
 /* Print a pedantic warning.  The warning reason may be given in REASON.  */
 
 bool
-cpp_pedwarning (cpp_reader * pfile, int reason, const char *msgid, ...)
+cpp_pedwarning (cpp_reader * pfile, enum cpp_warning_reason reason,
+		const char *msgid, ...)
 {
   va_list ap;
   bool ret;
@@ -143,7 +130,8 @@
    given in REASON.  */
 
 bool
-cpp_warning_syshdr (cpp_reader * pfile, int reason, const char *msgid, ...)
+cpp_warning_syshdr (cpp_reader * pfile, enum cpp_warning_reason reason,
+		    const char *msgid, ...)
 {
   va_list ap;
   bool ret;
@@ -160,18 +148,19 @@
 
 ATTRIBUTE_FPTR_PRINTF(6,0)
 static bool
-cpp_diagnostic_with_line (cpp_reader * pfile, int level, int reason,
-		          source_location src_loc, unsigned int column,
-		          const char *msgid, va_list *ap)
+cpp_diagnostic_with_line (cpp_reader * pfile, enum cpp_diagnostic_level level,
+			  enum cpp_warning_reason reason,
+			  source_location src_loc, unsigned int column,
+			  const char *msgid, va_list *ap)
 {
   bool ret;
   
-  if (!pfile->cb.error)
+  if (!pfile->cb.diagnostic)
     abort ();
   rich_location richloc (pfile->line_table, src_loc);
   if (column)
     richloc.override_column (column);
-  ret = pfile->cb.error (pfile, level, reason, &richloc, _(msgid), ap);
+  ret = pfile->cb.diagnostic (pfile, level, reason, &richloc, _(msgid), ap);
 
   return ret;
 }
@@ -179,7 +168,7 @@
 /* Print a warning or error, depending on the value of LEVEL.  */
 
 bool
-cpp_error_with_line (cpp_reader *pfile, int level,
+cpp_error_with_line (cpp_reader *pfile, enum cpp_diagnostic_level level,
 		     source_location src_loc, unsigned int column,
 		     const char *msgid, ...)
 {
@@ -198,7 +187,7 @@
 /* Print a warning.  The warning reason may be given in REASON.  */
 
 bool
-cpp_warning_with_line (cpp_reader *pfile, int reason,
+cpp_warning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason,
 		       source_location src_loc, unsigned int column,
 		       const char *msgid, ...)
 {
@@ -217,9 +206,9 @@
 /* Print a pedantic warning.  The warning reason may be given in REASON.  */
 
 bool
-cpp_pedwarning_with_line (cpp_reader *pfile, int reason,
-		          source_location src_loc, unsigned int column,
-		          const char *msgid, ...)
+cpp_pedwarning_with_line (cpp_reader *pfile, enum cpp_warning_reason reason,
+			  source_location src_loc, unsigned int column,
+			  const char *msgid, ...)
 {
   va_list ap;
   bool ret;
@@ -237,9 +226,9 @@
    given in REASON.  */
 
 bool
-cpp_warning_with_line_syshdr (cpp_reader *pfile, int reason,
-		              source_location src_loc, unsigned int column,
-		              const char *msgid, ...)
+cpp_warning_with_line_syshdr (cpp_reader *pfile, enum cpp_warning_reason reason,
+			      source_location src_loc, unsigned int column,
+			      const char *msgid, ...)
 {
   va_list ap;
   bool ret;
@@ -257,15 +246,16 @@
    a column override.  */
 
 bool
-cpp_error_at (cpp_reader * pfile, int level, source_location src_loc,
-	      const char *msgid, ...)
+cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
+	      source_location src_loc, const char *msgid, ...)
 {
   va_list ap;
   bool ret;
 
   va_start (ap, msgid);
 
-  ret = cpp_diagnostic_at (pfile, level, CPP_W_NONE, src_loc,
+  rich_location richloc (pfile->line_table, src_loc);
+  ret = cpp_diagnostic_at (pfile, level, CPP_W_NONE, &richloc,
 			   msgid, &ap);
 
   va_end (ap);
@@ -276,16 +266,16 @@
    a column override.  */
 
 bool
-cpp_error_at_richloc (cpp_reader * pfile, int level, rich_location *richloc,
-		      const char *msgid, ...)
+cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level level,
+	      rich_location *richloc, const char *msgid, ...)
 {
   va_list ap;
   bool ret;
 
   va_start (ap, msgid);
 
-  ret = cpp_diagnostic_at_richloc (pfile, level, CPP_W_NONE, richloc,
-				   msgid, &ap);
+  ret = cpp_diagnostic_at (pfile, level, CPP_W_NONE, richloc,
+			   msgid, &ap);
 
   va_end (ap);
   return ret;
@@ -295,7 +285,8 @@
    information from errno.  */
 
 bool
-cpp_errno (cpp_reader *pfile, int level, const char *msgid)
+cpp_errno (cpp_reader *pfile, enum cpp_diagnostic_level level,
+	   const char *msgid)
 {
   return cpp_error (pfile, level, "%s: %s", _(msgid), xstrerror (errno));
 }
@@ -305,7 +296,8 @@
    that is not localized, but "" is replaced with localized "stdout".  */
 
 bool
-cpp_errno_filename (cpp_reader *pfile, int level, const char *filename,
+cpp_errno_filename (cpp_reader *pfile, enum cpp_diagnostic_level level,
+		    const char *filename,
 		    source_location loc)
 {
   if (filename[0] == '\0')