From a6f624bd60682f85db63c4513c2bd70aadd7e3c3 Mon Sep 17 00:00:00 2001 From: burnus Date: Fri, 13 Feb 2009 22:16:20 +0000 Subject: [PATCH] 2009-02-13 Mikael Morin PR fortran/38259 * module.c (gfc_dump_module,gfc_use_module): Add module version number. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144169 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/module.c | 25 ++++++++++++++++++++++--- 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 + + PR fortran/38259 + * module.c (gfc_dump_module,gfc_use_module): Add module + version number. + 2009-02-13 Paul Thomas 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++; -- 2.11.0