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
This commit is contained in:
Mikael Morin 2009-02-13 23:16:20 +01:00 committed by Tobias Burnus
parent c208436c7b
commit 2d05f84dc4
2 changed files with 28 additions and 3 deletions

View File

@ -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

View File

@ -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++;