summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog12
-rw-r--r--libcpp/errors.c16
-rw-r--r--libcpp/files.c11
-rw-r--r--libcpp/include/cpplib.h3
4 files changed, 35 insertions, 7 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 5a87c1791c4..ce294ae88ab 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,15 @@
+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-11-13 David Malcolm <dmalcolm@redhat.com>
* errors.c (cpp_diagnostic): Pass pfile->line_table to
diff --git a/libcpp/errors.c b/libcpp/errors.c
index 8790e10f5c8..c27a417e886 100644
--- a/libcpp/errors.c
+++ b/libcpp/errors.c
@@ -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));
}
diff --git a/libcpp/files.c b/libcpp/files.c
index 8c388d87d80..5f532d35baa 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -715,7 +715,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;
}
@@ -1053,7 +1053,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
{
@@ -1067,9 +1068,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);
}
}
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index f5c2a21e952..3cb8cce3dfa 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -986,6 +986,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