diff options
author | Mikael Morin <mikael.morin@tele2.fr> | 2009-02-13 23:16:20 +0100 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2009-02-13 23:16:20 +0100 |
commit | 2d05f84dc4adbeb3881a7d7b27b65520aef8bb5c (patch) | |
tree | 10a2000b05efd08c3d6a77fe2835ac2e46b1f1de /gcc/fortran | |
parent | c208436c7bef0b3d4aa15073347404b9178e9280 (diff) | |
download | gcc-2d05f84dc4adbeb3881a7d7b27b65520aef8bb5c.zip gcc-2d05f84dc4adbeb3881a7d7b27b65520aef8bb5c.tar.gz gcc-2d05f84dc4adbeb3881a7d7b27b65520aef8bb5c.tar.bz2 |
re PR fortran/38259 (Add version number to .mod file)
2009-02-13 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/38259
* module.c (gfc_dump_module,gfc_use_module): Add module
version number.
From-SVN: r144169
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/module.c | 25 |
2 files changed, 28 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 589db07..2cd5447 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 09c3e20..bfc4ef9 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++; |