Hi all, I like to take Jakub's patch a little bit further and add two things, that annoy me:
First of all the recursive attr must not be set on vtypes, neither on module ones nor anywhere else. Strictly speaking is a vtype recursive, because by its extends member it references itself through a pointer. But it is guaranteed that the base type is never the same as the extended one. So no cycle can occur. Furthermore are vtypes never freeed nor copied (yet). So the flag is not needed which the patch starting with 0002 ensures. Secondly is the third parameter of the macro in the iso-fortran-env.def file a type kind, i.e. an integer. I see no reason why there is that special treatment in module.cc. The kinds can not be defined in iso-fortran-env and therefore no hither and further referencing is possible. Including the file again, just relying on order in the file, is in my opinion dangerous. And if required must have been documented thoroughly, what I don't see. Just storing the kind immediately as it is done by the patch starting with 0003 does all that is needed. I have included Jakub's original patch as 0001-* for easier application with `git am` and testing it yourself. Regtests ok on x86_64-pc-linux-gnu / F41. Ok for mainline? Regards and many thanks to all your valued input and patches, Andre On Wed, 8 Jan 2025 16:34:18 +0100 Jakub Jelinek <ja...@redhat.com> wrote: > On Wed, Jan 08, 2025 at 04:09:36PM +0100, Andre Vehreschild wrote: > > One of the issues are lines: > > > > module.cc 7125-7130: Here it is assumed that the signed and unsigned types > > are adjacent maybe?! > > > > I have changed this: > > > > diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc > > index c4312b641c1..05bc802957e 100644 > > --- a/gcc/fortran/module.cc > > +++ b/gcc/fortran/module.cc > > @@ -7113,8 +7113,8 @@ use_iso_fortran_env_module (void) > > int i, j; > > > > intmod_sym symbol[] = { > > -#define NAMED_INTCST(a,b,c,d) { a, b, 0, d }, > > -#define NAMED_UINTCST(a,b,c,d) { a, b, 0, d }, > > +#define NAMED_INTCST(a, b, c, d) {a, b, c, d}, > > +#define NAMED_UINTCST(a, b, c, d) {a, b, c, d}, > > #define NAMED_KINDARRAY(a,b,c,d) { a, b, 0, d }, > > #define NAMED_DERIVED_TYPE(a,b,c,d) { a, b, 0, d }, > > #define NAMED_FUNCTION(a,b,c,d) { a, b, c, d }, > > @@ -7122,12 +7122,12 @@ use_iso_fortran_env_module (void) > > #include "iso-fortran-env.def" > > { ISOFORTRANENV_INVALID, NULL, -1234, 0 } }; > > > > - i = 0; > > -#define NAMED_INTCST(a,b,c,d) symbol[i++].value = c; > > -#include "iso-fortran-env.def" > > + // i = 0; > > + // #define NAMED_INTCST(a,b,c,d) symbol[i++].value = c; > > + // #include "iso-fortran-env.def" > > > > -#define NAMED_UINTCST(a,b,c,d) symbol[i++].value = c; > > -#include "iso-fortran-env.def" > > + // #define NAMED_UINTCST(a,b,c,d) symbol[i++].value = c; > > + // #include "iso-fortran-env.def" > > > > /* Generate the symbol for the module itself. */ > > mod_symtree = gfc_find_symtree (gfc_current_ns->sym_root, mod); > > > > > > And at least iso_fortran_env_8.f90 does not fail anymore. > > I'm testing for that instead: > --- gcc/module.cc.jj 2025-01-08 15:23:54.511732946 +0100 > +++ gcc/module.cc 2025-01-08 16:32:14.963984426 +0100 > @@ -7122,9 +7122,11 @@ use_iso_fortran_env_module (void) > > i = 0; > #define NAMED_INTCST(a,b,c,d) symbol[i++].value = c; > -#include "iso-fortran-env.def" > - > #define NAMED_UINTCST(a,b,c,d) symbol[i++].value = c; > +#define NAMED_KINDARRAY(a,b,c,d) i++; > +#define NAMED_DERIVED_TYPE(a,b,c,d) i++; > +#define NAMED_FUNCTION(a,b,c,d) i++; > +#define NAMED_SUBROUTINE(a,b,c,d) i++; > #include "iso-fortran-env.def" > > /* Generate the symbol for the module itself. */ > > Jakub > -- Andre Vehreschild * Email: vehre ad gmx dot de
From d17c5db39148c6b9226272e32e1f311cadddcd4a Mon Sep 17 00:00:00 2001 From: Andre Vehreschild <ve...@gcc.gnu.org> Date: Wed, 8 Jan 2025 17:05:59 +0100 Subject: [PATCH 3/3] Fortran: Fixup iso_fortran_env symbol numbering [PR118337] gcc/fortran/ChangeLog: PR fortran/118337 * module.cc (use_iso_fortran_env_module): Prevent additional run over (un-)signed ints and assign kind directly. --- gcc/fortran/module.cc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index de8df05781d..8dc10e1d349 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -7113,8 +7113,8 @@ use_iso_fortran_env_module (void) int i, j; intmod_sym symbol[] = { -#define NAMED_INTCST(a,b,c,d) { a, b, 0, d }, -#define NAMED_UINTCST(a,b,c,d) { a, b, 0, d }, +#define NAMED_INTCST(a, b, c, d) {a, b, c, d}, +#define NAMED_UINTCST(a, b, c, d) {a, b, c, d}, #define NAMED_KINDARRAY(a,b,c,d) { a, b, 0, d }, #define NAMED_DERIVED_TYPE(a,b,c,d) { a, b, 0, d }, #define NAMED_FUNCTION(a,b,c,d) { a, b, c, d }, @@ -7122,15 +7122,6 @@ use_iso_fortran_env_module (void) #include "iso-fortran-env.def" { ISOFORTRANENV_INVALID, NULL, -1234, 0 } }; - i = 0; -#define NAMED_INTCST(a,b,c,d) symbol[i++].value = c; -#define NAMED_UINTCST(a,b,c,d) symbol[i++].value = c; -#define NAMED_KINDARRAY(a,b,c,d) i++; -#define NAMED_DERIVED_TYPE(a,b,c,d) i++; -#define NAMED_FUNCTION(a,b,c,d) i++; -#define NAMED_SUBROUTINE(a,b,c,d) i++; -#include "iso-fortran-env.def" - /* Generate the symbol for the module itself. */ mod_symtree = gfc_find_symtree (gfc_current_ns->sym_root, mod); if (mod_symtree == NULL) -- 2.47.1
From d0b43ccb141dbec998e81fd437f7f1a02bd74731 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild <ve...@gcc.gnu.org> Date: Wed, 8 Jan 2025 14:58:35 +0100 Subject: [PATCH 2/3] Fortran: Cylce detection for non vtypes only. [PR118337] gcc/fortran/ChangeLog: PR fortran/118337 * resolve.cc (resolve_fl_derived0): Exempt vtypes from cycle detection. --- gcc/fortran/resolve.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 6dcda70679f..dab0c3af601 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -16840,7 +16840,8 @@ resolve_fl_derived0 (gfc_symbol *sym) /* Resolving components below, may create vtabs for which the cyclic type information needs to be present. */ - resolve_cyclic_derived_type (sym); + if (!sym->attr.vtype) + resolve_cyclic_derived_type (sym); c = (sym->attr.is_class) ? CLASS_DATA (sym->components) : sym->components; -- 2.47.1
From db2b2fa823c6d74b5df208d04f470fe7a91b2c61 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild <ve...@gcc.gnu.org> Date: Wed, 8 Jan 2025 17:21:04 +0100 Subject: [PATCH 1/3] Fortran: Accept "15" modules for compatibility [PR118337] gcc/fortran/ChangeLog: 2025-01-08 Jakub Jelinek <ja...@redhat.com> PR fortran/118337 * module.cc (COMPAT_MOD_VERSIONS): Define. (use_iso_fortran_env_module): Don't assume all NAMED_INTCSTs come first followed by NAMED_UINTCSTs. (gfc_use_module): Accept also COMPAT_MOD_VERSIONS for compatibility. * iso-c-binding.def: Reorder entries so that the GCC 14 ones come before the ones new in GCC 15. * iso-fortran-env.def: Likewise. --- gcc/fortran/iso-c-binding.def | 115 ++++++++++++++++---------------- gcc/fortran/iso-fortran-env.def | 42 ++++++------ gcc/fortran/module.cc | 27 ++++++-- 3 files changed, 103 insertions(+), 81 deletions(-) diff --git a/gcc/fortran/iso-c-binding.def b/gcc/fortran/iso-c-binding.def index 14239cb849e..a9159d24302 100644 --- a/gcc/fortran/iso-c-binding.def +++ b/gcc/fortran/iso-c-binding.def @@ -17,7 +17,8 @@ along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ /* This file contains the definition of the types provided by the - Fortran 2003 ISO_C_BINDING intrinsic module. */ + Fortran 2003 ISO_C_BINDING intrinsic module. The ordering of + the entries matters for the *.mod backwards compatibility. */ #ifndef NAMED_INTCST # define NAMED_INTCST(a,b,c,d) @@ -112,62 +113,6 @@ NAMED_INTCST (ISOCBINDING_INT_FAST64_T, "c_int_fast64_t", \ NAMED_INTCST (ISOCBINDING_INT_FAST128_T, "c_int_fast128_t", get_int_kind_from_width (128), GFC_STD_GNU) -/* UNSIGNED. */ -NAMED_UINTCST (ISOCBINDING_UINT, "c_unsigned", gfc_c_uint_kind, \ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_USHORT, "c_unsigned_short", \ - get_unsigned_kind_from_node (short_unsigned_type_node), \ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UCHAR, "c_unsigned_char", \ - get_unsigned_kind_from_node (unsigned_char_type_node), \ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_ULONG, "c_unsigned_long", \ - get_unsigned_kind_from_node (long_unsigned_type_node), \ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_ULONGLONG, "c_unsigned_long_long", \ - get_unsigned_kind_from_node (long_long_unsigned_type_node), \ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINTMAX_T, "c_uintmax_t", \ - get_uint_kind_from_name (UINTMAX_TYPE), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT8_T, "c_uint8_t", \ - get_uint_kind_from_name (UINT8_TYPE), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT16_T, "c_uint16_t", \ - get_uint_kind_from_name (UINT16_TYPE), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT32_T, "c_uint32_t", \ - get_uint_kind_from_name (UINT32_TYPE), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT64_T, "c_uint64_t", \ - get_uint_kind_from_name (UINT64_TYPE), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT128_T, "c_uint128_t", \ - get_uint_kind_from_width (128), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_LEAST8_T, "c_uint_least8_t", \ - get_uint_kind_from_name (UINT_LEAST8_TYPE), \ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_LEAST16_T, "c_uint_least16_t", \ - get_uint_kind_from_name (UINT_LEAST16_TYPE), \ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_LEAST32_T, "c_uint_least32_t", \ - get_uint_kind_from_name (UINT_LEAST32_TYPE),\ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_LEAST64_T, "c_uint_least64_t", \ - get_uint_kind_from_name (UINT_LEAST64_TYPE),\ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_LEAST128_T, "c_uint_least128_t", \ - get_uint_kind_from_width (128), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_FAST8_T, "c_uint_fast8_t", \ - get_uint_kind_from_name (UINT_FAST8_TYPE), \ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_FAST16_T, "c_uint_fast16_t", \ - get_uint_kind_from_name (UINT_FAST16_TYPE), \ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_FAST32_T, "c_uint_fast32_t", \ - get_uint_kind_from_name (UINT_FAST32_TYPE),\ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_FAST64_T, "c_uint_fast64_t", \ - get_uint_kind_from_name (UINT_FAST64_TYPE),\ - GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOCBINDING_UINT_FAST128_T, "c_uint_fast128_t", \ - get_uint_kind_from_width (128), GFC_STD_UNSIGNED) - NAMED_REALCST (ISOCBINDING_FLOAT, "c_float", \ get_real_kind_from_node (float_type_node), GFC_STD_F2003) NAMED_REALCST (ISOCBINDING_DOUBLE, "c_double", \ @@ -259,6 +204,62 @@ NAMED_FUNCTION (ISOCBINDING_C_SIZEOF, "c_sizeof", \ NAMED_FUNCTION (ISOCBINDING_F_C_STRING, "f_c_string", \ GFC_ISYM_F_C_STRING, GFC_STD_F2023) +/* UNSIGNED. */ +NAMED_UINTCST (ISOCBINDING_UINT, "c_unsigned", gfc_c_uint_kind, \ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_USHORT, "c_unsigned_short", \ + get_unsigned_kind_from_node (short_unsigned_type_node), \ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UCHAR, "c_unsigned_char", \ + get_unsigned_kind_from_node (unsigned_char_type_node), \ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_ULONG, "c_unsigned_long", \ + get_unsigned_kind_from_node (long_unsigned_type_node), \ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_ULONGLONG, "c_unsigned_long_long", \ + get_unsigned_kind_from_node (long_long_unsigned_type_node), \ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINTMAX_T, "c_uintmax_t", \ + get_uint_kind_from_name (UINTMAX_TYPE), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT8_T, "c_uint8_t", \ + get_uint_kind_from_name (UINT8_TYPE), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT16_T, "c_uint16_t", \ + get_uint_kind_from_name (UINT16_TYPE), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT32_T, "c_uint32_t", \ + get_uint_kind_from_name (UINT32_TYPE), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT64_T, "c_uint64_t", \ + get_uint_kind_from_name (UINT64_TYPE), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT128_T, "c_uint128_t", \ + get_uint_kind_from_width (128), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_LEAST8_T, "c_uint_least8_t", \ + get_uint_kind_from_name (UINT_LEAST8_TYPE), \ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_LEAST16_T, "c_uint_least16_t", \ + get_uint_kind_from_name (UINT_LEAST16_TYPE), \ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_LEAST32_T, "c_uint_least32_t", \ + get_uint_kind_from_name (UINT_LEAST32_TYPE),\ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_LEAST64_T, "c_uint_least64_t", \ + get_uint_kind_from_name (UINT_LEAST64_TYPE),\ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_LEAST128_T, "c_uint_least128_t", \ + get_uint_kind_from_width (128), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_FAST8_T, "c_uint_fast8_t", \ + get_uint_kind_from_name (UINT_FAST8_TYPE), \ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_FAST16_T, "c_uint_fast16_t", \ + get_uint_kind_from_name (UINT_FAST16_TYPE), \ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_FAST32_T, "c_uint_fast32_t", \ + get_uint_kind_from_name (UINT_FAST32_TYPE),\ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_FAST64_T, "c_uint_fast64_t", \ + get_uint_kind_from_name (UINT_FAST64_TYPE),\ + GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOCBINDING_UINT_FAST128_T, "c_uint_fast128_t", \ + get_uint_kind_from_width (128), GFC_STD_UNSIGNED) + #undef NAMED_INTCST #undef NAMED_UINTCST #undef NAMED_REALCST diff --git a/gcc/fortran/iso-fortran-env.def b/gcc/fortran/iso-fortran-env.def index 3ecddb6c372..b8926f4df93 100644 --- a/gcc/fortran/iso-fortran-env.def +++ b/gcc/fortran/iso-fortran-env.def @@ -17,7 +17,8 @@ along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ /* This file contains the definition of the named integer constants provided - by the Fortran 2003 ISO_FORTRAN_ENV intrinsic module. */ + by the Fortran 2003 ISO_FORTRAN_ENV intrinsic module. The ordering of + the entries matters for the *.mod backwards compatibility. */ #ifndef NAMED_INTCST # define NAMED_INTCST(a,b,c,d) @@ -72,20 +73,10 @@ NAMED_INTCST (ISOFORTRANENV_IOSTAT_EOR, "iostat_eor", LIBERROR_EOR, \ NAMED_INTCST (ISOFORTRANENV_IOSTAT_INQUIRE_INTERNAL_UNIT, \ "iostat_inquire_internal_unit", LIBERROR_INQUIRE_INTERNAL_UNIT, \ GFC_STD_F2008) -NAMED_INTCST (ISOFORTRANENV_LOGICAL8, "logical8", \ - gfc_get_int_kind_from_width_isofortranenv (8), GFC_STD_F2023) -NAMED_INTCST (ISOFORTRANENV_LOGICAL16, "logical16", \ - gfc_get_int_kind_from_width_isofortranenv (16), GFC_STD_F2023) -NAMED_INTCST (ISOFORTRANENV_LOGICAL32, "logical32", \ - gfc_get_int_kind_from_width_isofortranenv (32), GFC_STD_F2023) -NAMED_INTCST (ISOFORTRANENV_LOGICAL64, "logical64", \ - gfc_get_int_kind_from_width_isofortranenv (64), GFC_STD_F2023) NAMED_INTCST (ISOFORTRANENV_NUMERIC_STORAGE_SIZE, "numeric_storage_size", \ gfc_numeric_storage_size, GFC_STD_F2003) NAMED_INTCST (ISOFORTRANENV_OUTPUT_UNIT, "output_unit", GFC_STDOUT_UNIT_NUMBER, \ GFC_STD_F2003) -NAMED_INTCST (ISOFORTRANENV_REAL16, "real16", \ - gfc_get_real_kind_from_width_isofortranenv (16), GFC_STD_F2023) NAMED_INTCST (ISOFORTRANENV_REAL32, "real32", \ gfc_get_real_kind_from_width_isofortranenv (32), GFC_STD_F2008) NAMED_INTCST (ISOFORTRANENV_REAL64, "real64", \ @@ -103,14 +94,7 @@ NAMED_INTCST (ISOFORTRANENV_FILE_STAT_FAILED_IMAGE, "stat_failed_image", \ GFC_STAT_FAILED_IMAGE, GFC_STD_F2018) NAMED_INTCST (ISOFORTRANENV_FILE_STAT_UNLOCKED, "stat_unlocked", \ GFC_STAT_UNLOCKED, GFC_STD_F2008) -NAMED_UINTCST (ISOFORTRANENV_UINT8, "uint8", \ - gfc_get_uint_kind_from_width_isofortranenv (8), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOFORTRANENV_UINT16, "uint16", \ - gfc_get_uint_kind_from_width_isofortranenv (16), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOFORTRANENV_UINT32, "uint32", \ - gfc_get_uint_kind_from_width_isofortranenv (32), GFC_STD_UNSIGNED) -NAMED_UINTCST (ISOFORTRANENV_UINT64, "uint64", \ - gfc_get_uint_kind_from_width_isofortranenv (64), GFC_STD_UNSIGNED) + /* The arguments to NAMED_KINDARRAY are: -- an internal name @@ -154,6 +138,26 @@ NAMED_DERIVED_TYPE (ISOFORTRAN_TEAM_TYPE, "team_type", \ ? get_int_kind_from_node (ptr_type_node) : gfc_default_integer_kind, GFC_STD_F2018) +NAMED_INTCST (ISOFORTRANENV_LOGICAL8, "logical8", \ + gfc_get_int_kind_from_width_isofortranenv (8), GFC_STD_F2023) +NAMED_INTCST (ISOFORTRANENV_LOGICAL16, "logical16", \ + gfc_get_int_kind_from_width_isofortranenv (16), GFC_STD_F2023) +NAMED_INTCST (ISOFORTRANENV_LOGICAL32, "logical32", \ + gfc_get_int_kind_from_width_isofortranenv (32), GFC_STD_F2023) +NAMED_INTCST (ISOFORTRANENV_LOGICAL64, "logical64", \ + gfc_get_int_kind_from_width_isofortranenv (64), GFC_STD_F2023) +NAMED_INTCST (ISOFORTRANENV_REAL16, "real16", \ + gfc_get_real_kind_from_width_isofortranenv (16), GFC_STD_F2023) + +NAMED_UINTCST (ISOFORTRANENV_UINT8, "uint8", \ + gfc_get_uint_kind_from_width_isofortranenv (8), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOFORTRANENV_UINT16, "uint16", \ + gfc_get_uint_kind_from_width_isofortranenv (16), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOFORTRANENV_UINT32, "uint32", \ + gfc_get_uint_kind_from_width_isofortranenv (32), GFC_STD_UNSIGNED) +NAMED_UINTCST (ISOFORTRANENV_UINT64, "uint64", \ + gfc_get_uint_kind_from_width_isofortranenv (64), GFC_STD_UNSIGNED) + #undef NAMED_INTCST #undef NAMED_UINTCST #undef NAMED_KINDARRAY diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc index 6ac51d7c3b1..de8df05781d 100644 --- a/gcc/fortran/module.cc +++ b/gcc/fortran/module.cc @@ -84,7 +84,9 @@ along with GCC; see the file COPYING3. If not see /* Don't put any single quote (') in MOD_VERSION, if you want it to be recognized. */ -#define MOD_VERSION "15" +#define MOD_VERSION "16" +/* Older mod versions we can still parse. */ +#define COMPAT_MOD_VERSIONS {"15"} /* Structure that describes a position within a module file. */ @@ -7122,9 +7124,11 @@ use_iso_fortran_env_module (void) i = 0; #define NAMED_INTCST(a,b,c,d) symbol[i++].value = c; -#include "iso-fortran-env.def" - #define NAMED_UINTCST(a,b,c,d) symbol[i++].value = c; +#define NAMED_KINDARRAY(a,b,c,d) i++; +#define NAMED_DERIVED_TYPE(a,b,c,d) i++; +#define NAMED_FUNCTION(a,b,c,d) i++; +#define NAMED_SUBROUTINE(a,b,c,d) i++; #include "iso-fortran-env.def" /* Generate the symbol for the module itself. */ @@ -7451,10 +7455,23 @@ gfc_use_module (gfc_use_list *module) " module file", module_fullpath); if (start == 3) { + bool fatal = false; if (strcmp (atom_name, " version") != 0 || module_char () != ' ' - || parse_atom () != ATOM_STRING - || strcmp (atom_string, MOD_VERSION)) + || parse_atom () != ATOM_STRING) + fatal = true; + else if (strcmp (atom_string, MOD_VERSION)) + { + static const char *compat_mod_versions[] = COMPAT_MOD_VERSIONS; + fatal = true; + for (unsigned i = 0; i < ARRAY_SIZE (compat_mod_versions); ++i) + if (!strcmp (atom_string, compat_mod_versions[i])) + { + fatal = false; + break; + } + } + if (fatal) gfc_fatal_error ("Cannot read module file %qs opened at %C," " because it was created by a different" " version of GNU Fortran", module_fullpath); -- 2.47.1