From: Harald Anlauf Date: Tue, 12 Nov 2019 21:14:19 +0000 (+0000) Subject: re PR fortran/81651 (Enhancement request: have f951 print out fully qualified module... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c72b04bf1b21ef6256844d06fd7e7b2db318eab;p=gcc.git re PR fortran/81651 (Enhancement request: have f951 print out fully qualified module file name) 2019-11-12 Harald Anlauf PR fortran/81651 * module.c (gzopen_included_file, gzopen_included_file_1) (gzopen_intrinsic_module, bad_module, gfc_use_module): Use fully qualified module path for error reporting. From-SVN: r278105 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 92a71a3c155..876a9bbd6e7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2019-11-12 Harald Anlauf + + PR fortran/81651 + * module.c (gzopen_included_file, gzopen_included_file_1) + (gzopen_intrinsic_module, bad_module, gfc_use_module): Use fully + qualified module path for error reporting. + 2019-11-12 Martin Liska * options.c (gfc_init_options): diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 1ca15352e7e..755f237a0e7 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -187,6 +187,8 @@ pointer_info; /* The gzFile for the module we're reading or writing. */ static gzFile module_fp; +/* Fully qualified module path */ +static char *module_fullpath = NULL; /* The name of the module we're reading (USE'ing) or writing. */ static const char *module_name; @@ -1101,6 +1103,8 @@ gzopen_included_file_1 (const char *name, gfc_directorylist *list, if (gfc_cpp_makedep ()) gfc_cpp_add_dep (fullname, system); + free (module_fullpath); + module_fullpath = xstrdup (fullname); return f; } } @@ -1116,8 +1120,14 @@ gzopen_included_file (const char *name, bool include_cwd, bool module) if (IS_ABSOLUTE_PATH (name) || include_cwd) { f = gzopen (name, "r"); - if (f && gfc_cpp_makedep ()) - gfc_cpp_add_dep (name, false); + if (f) + { + if (gfc_cpp_makedep ()) + gfc_cpp_add_dep (name, false); + + free (module_fullpath); + module_fullpath = xstrdup (name); + } } if (!f) @@ -1134,8 +1144,14 @@ gzopen_intrinsic_module (const char* name) if (IS_ABSOLUTE_PATH (name)) { f = gzopen (name, "r"); - if (f && gfc_cpp_makedep ()) - gfc_cpp_add_dep (name, true); + if (f) + { + if (gfc_cpp_makedep ()) + gfc_cpp_add_dep (name, true); + + free (module_fullpath); + module_fullpath = xstrdup (name); + } } if (!f) @@ -1181,7 +1197,7 @@ bad_module (const char *msgid) { case IO_INPUT: gfc_fatal_error ("Reading module %qs at line %d column %d: %s", - module_name, module_line, module_column, msgid); + module_fullpath, module_line, module_column, msgid); break; case IO_OUTPUT: gfc_fatal_error ("Writing module %qs at line %d column %d: %s", @@ -7141,7 +7157,7 @@ gfc_use_module (gfc_use_list *module) if ((start == 1 && strcmp (atom_name, "GFORTRAN") != 0) || (start == 2 && strcmp (atom_name, " module") != 0)) gfc_fatal_error ("File %qs opened at %C is not a GNU Fortran" - " module file", filename); + " module file", module_fullpath); if (start == 3) { if (strcmp (atom_name, " version") != 0 @@ -7150,7 +7166,7 @@ gfc_use_module (gfc_use_list *module) || strcmp (atom_string, MOD_VERSION)) gfc_fatal_error ("Cannot read module file %qs opened at %C," " because it was created by a different" - " version of GNU Fortran", filename); + " version of GNU Fortran", module_fullpath); free (atom_string); }