aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog8
-rw-r--r--libgfortran/gfortran.map5
-rw-r--r--libgfortran/libgfortran.h4
-rw-r--r--libgfortran/runtime/error.c46
4 files changed, 62 insertions, 1 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 7a11ca2..23a4c57 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,11 @@
+2019-08-17 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR fortran/68401
+ * gfortran.map: Add GFORTRAN_10 node, add _gfortran_os_error_at
+ symbol.
+ * libgfortran.h (os_error_at): New prototype.
+ * runtime/error.c (os_error_at): New function.
+
2019-08-13 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/91414
diff --git a/libgfortran/gfortran.map b/libgfortran/gfortran.map
index 2b2243b..3601bc2 100644
--- a/libgfortran/gfortran.map
+++ b/libgfortran/gfortran.map
@@ -1602,3 +1602,8 @@ GFORTRAN_9.2 {
_gfortran_mfindloc1_r10;
_gfortran_sfindloc1_r10;
} GFORTRAN_9;
+
+GFORTRAN_10 {
+ global:
+ _gfortran_os_error_at;
+} GFORTRAN_9.2;
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index c0db96f..9f535b1 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -728,6 +728,10 @@ internal_proto(gfc_xtoa);
extern _Noreturn void os_error (const char *);
iexport_proto(os_error);
+extern _Noreturn void os_error_at (const char *, const char *, ...)
+ __attribute__ ((format (gfc_printf, 2, 3)));
+iexport_proto(os_error_at);
+
extern void show_locus (st_parameter_common *);
internal_proto(show_locus);
diff --git a/libgfortran/runtime/error.c b/libgfortran/runtime/error.c
index 0335a16..cbe0642 100644
--- a/libgfortran/runtime/error.c
+++ b/libgfortran/runtime/error.c
@@ -403,7 +403,51 @@ os_error (const char *message)
estr_writev (iov, 5);
exit_error (1);
}
-iexport(os_error);
+iexport(os_error); /* TODO, DEPRECATED, ABI: Should not be exported
+ anymore when bumping so version. */
+
+
+/* Improved version of os_error with a printf style format string and
+ a locus. */
+
+void
+os_error_at (const char *where, const char *message, ...)
+{
+ char errmsg[STRERR_MAXSZ];
+ char buffer[STRERR_MAXSZ];
+ struct iovec iov[6];
+ va_list ap;
+ recursion_check ();
+ int written;
+
+ iov[0].iov_base = (char*) where;
+ iov[0].iov_len = strlen (where);
+
+ iov[1].iov_base = (char*) ": ";
+ iov[1].iov_len = strlen (iov[1].iov_base);
+
+ va_start (ap, message);
+ written = vsnprintf (buffer, STRERR_MAXSZ, message, ap);
+ va_end (ap);
+ iov[2].iov_base = buffer;
+ if (written >= 0)
+ iov[2].iov_len = written;
+ else
+ iov[2].iov_len = 0;
+
+ iov[3].iov_base = (char*) ": ";
+ iov[3].iov_len = strlen (iov[3].iov_base);
+
+ iov[4].iov_base = gf_strerror (errno, errmsg, STRERR_MAXSZ);
+ iov[4].iov_len = strlen (iov[4].iov_base);
+
+ iov[5].iov_base = (char*) "\n";
+ iov[5].iov_len = 1;
+
+ estr_writev (iov, 6);
+ exit_error (1);
+}
+iexport(os_error_at);
/* void runtime_error()-- These are errors associated with an