]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR preprocessor/60736 (Crash in preprocessor including stdc-predef.h...
authorJakub Jelinek <jakub@redhat.com>
Thu, 11 Feb 2016 09:03:34 +0000 (10:03 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 11 Feb 2016 09:03:34 +0000 (10:03 +0100)
Backported from mainline
2015-11-19  Jakub Jelinek  <jakub@redhat.com>

PR preprocessor/60736
* include/cpplib.h (cpp_errno_filename): New prototype.
* errors.c (cpp_errno): Don't handle msgid "" specially, use
_(msgid) instead of msgid as argument to cpp_error.
(cpp_errno_filename): New function.
* files.c (read_file_guts): Use cpp_errno_filename instead of
cpp_errno.
(open_file_failed): Likewise.  Use file->name if file->path is NULL
in diagnostics.

From-SVN: r233318

libcpp/ChangeLog
libcpp/errors.c
libcpp/files.c
libcpp/include/cpplib.h

index 2cb99a0067e59898f1e53a4f2512dc59a528285e..0decbe9c36b5ea6e62186736e38d01dd98b8d8fe 100644 (file)
@@ -1,3 +1,18 @@
+2016-02-11  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2015-11-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR preprocessor/60736
+       * include/cpplib.h (cpp_errno_filename): New prototype.
+       * errors.c (cpp_errno): Don't handle msgid "" specially, use
+       _(msgid) instead of msgid as argument to cpp_error.
+       (cpp_errno_filename): New function.
+       * files.c (read_file_guts): Use cpp_errno_filename instead of
+       cpp_errno.
+       (open_file_failed): Likewise.  Use file->name if file->path is NULL
+       in diagnostics.
+
 2015-06-26  Release Manager
 
        * GCC 4.9.3 released.
index d1ca7a12ff42c72f873a9a4af7061f796524578b..3e7aeae3817a947b4aa5d1274c605d8dee67b7d0 100644 (file)
@@ -230,8 +230,18 @@ cpp_warning_with_line_syshdr (cpp_reader *pfile, int reason,
 bool
 cpp_errno (cpp_reader *pfile, int level, const char *msgid)
 {
-  if (msgid[0] == '\0')
-    msgid = _("stdout");
+  return cpp_error (pfile, level, "%s: %s", _(msgid), xstrerror (errno));
+}
+
+/* Print a warning or error, depending on the value of LEVEL.  Include
+   information from errno.  Unlike cpp_errno, the argument is a filename
+   that is not localized, but "" is replaced with localized "stdout".  */
+
+bool
+cpp_errno_filename (cpp_reader *pfile, int level, const char *filename)
+{
+  if (filename[0] == '\0')
+    filename = _("stdout");
 
-  return cpp_error (pfile, level, "%s: %s", msgid, xstrerror (errno));
+  return cpp_error (pfile, level, "%s: %s", filename, xstrerror (errno));
 }
index f9834951c2f4a73330403cb6e7070ca75961e356..144c0bc8260253331a52253e640a4ac7bd6b152b 100644 (file)
@@ -709,7 +709,7 @@ read_file_guts (cpp_reader *pfile, _cpp_file *file)
 
   if (count < 0)
     {
-      cpp_errno (pfile, CPP_DL_ERROR, file->path);
+      cpp_errno_filename (pfile, CPP_DL_ERROR, file->path);
       free (buf);
       return false;
     }
@@ -1035,7 +1035,8 @@ open_file_failed (cpp_reader *pfile, _cpp_file *file, int angle_brackets)
       /* If the preprocessor output (other than dependency information) is
          being used, we must also flag an error.  */
       if (CPP_OPTION (pfile, deps.need_preprocessor_output))
-       cpp_errno (pfile, CPP_DL_FATAL, file->path);
+       cpp_errno_filename (pfile, CPP_DL_FATAL,
+                           file->path ? file->path : file->name);
     }
   else
     {
@@ -1049,9 +1050,11 @@ open_file_failed (cpp_reader *pfile, _cpp_file *file, int angle_brackets)
       if (CPP_OPTION (pfile, deps.style) == DEPS_NONE
           || print_dep
           || CPP_OPTION (pfile, deps.need_preprocessor_output))
-       cpp_errno (pfile, CPP_DL_FATAL, file->path);
+       cpp_errno_filename (pfile, CPP_DL_FATAL,
+                           file->path ? file->path : file->name);
       else
-       cpp_errno (pfile, CPP_DL_WARNING, file->path);
+       cpp_errno_filename (pfile, CPP_DL_WARNING,
+                           file->path ? file->path : file->name);
     }
 }
 
index a9db7abbd2674dcde95faba02235450e80f33841..89333febe4f32650b0b316b71d8218e6f0846d19 100644 (file)
@@ -949,6 +949,9 @@ extern bool cpp_warning_syshdr (cpp_reader *, int, const char *msgid, ...)
 /* Output a diagnostic with "MSGID: " preceding the
    error string of errno.  No location is printed.  */
 extern bool cpp_errno (cpp_reader *, int, const char *msgid);
+/* Similarly, but with "FILENAME: " instead of "MSGID: ", where
+   the filename is not localized.  */
+extern bool cpp_errno_filename (cpp_reader *, int, const char *filename);
 
 /* Same as cpp_error, except additionally specifies a position as a
    (translation unit) physical line and physical column.  If the line is