summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/module.c25
2 files changed, 28 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 589db075e1b..2cd54474726 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-13 Mikael Morin <mikael.morin@tele2.fr>
+
+ PR fortran/38259
+ * module.c (gfc_dump_module,gfc_use_module): Add module
+ version number.
+
2009-02-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36703
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 09c3e20e312..bfc4ef9f0d2 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -75,6 +75,10 @@ along with GCC; see the file COPYING3. If not see
#define MODULE_EXTENSION ".mod"
+/* Don't put any single quote (') in MOD_VERSION,
+ if yout want it to be recognized. */
+#define MOD_VERSION "0"
+
/* Structure that describes a position within a module file. */
@@ -4817,8 +4821,8 @@ gfc_dump_module (const char *name, int dump_flag)
*strchr (p, '\n') = '\0';
- fprintf (module_fp, "GFORTRAN module created from %s on %s\nMD5:",
- gfc_source_file, p);
+ fprintf (module_fp, "GFORTRAN module version '%s' created from %s on %s\n"
+ "MD5:", MOD_VERSION, gfc_source_file, p);
fgetpos (module_fp, &md5_pos);
fputs ("00000000000000000000000000000000 -- "
"If you edit this, you'll get what you deserve.\n\n", module_fp);
@@ -5220,12 +5224,27 @@ gfc_use_module (void)
c = module_char ();
if (c == EOF)
bad_module ("Unexpected end of module");
- if (start++ < 2)
+ if (start++ < 3)
parse_name (c);
if ((start == 1 && strcmp (atom_name, "GFORTRAN") != 0)
|| (start == 2 && strcmp (atom_name, " module") != 0))
gfc_fatal_error ("File '%s' opened at %C is not a GFORTRAN module "
"file", filename);
+ if (start == 3)
+ {
+ if (strcmp (atom_name, " version") != 0
+ || module_char () != ' '
+ || parse_atom () != ATOM_STRING)
+ gfc_fatal_error ("Parse error when checking module version"
+ " for file '%s' opened at %C", filename);
+
+ if (strcmp (atom_string, MOD_VERSION))
+ {
+ gfc_fatal_error ("Wrong module version '%s' (expected '"
+ MOD_VERSION "') for file '%s' opened"
+ " at %C", atom_string, filename);
+ }
+ }
if (c == '\n')
line++;