This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, Fortran] PR33941 - Fix reading of modules with non-character intrinsic operators
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Tue, 30 Oct 2007 20:37:02 +0100
- Subject: [Patch, Fortran] PR33941 - Fix reading of modules with non-character intrinsic operators
:ADDPATCH fortran:
This fixes a 4.3 regression. Since a while, gfortran 4.3.0 distinguishes
between "<" and .LT. (for improved error messages). Since then, "<" is
written to the .mod file. However, the read-.mod parser did not
understand "<=" and gave an error. (This only occurs for the few cases
where for the interface intrinsic operators are used, e.g.
"character(len=...)" where ... contains e.g. "<".)
This patch simply adds support for the "/=" etc. intrinsic operators.
Build and regression tested on x86-64/Linux.
OK for the trunk?
A big thank to Dominique for reducing the test case and pointing to the
exact place where one had to change the source!
Tobias
2007-10-30 Tobias Burnus <burnus@net-b.de>
Dominique d'Humieres <dominiq@lps.ens.fr>
PR fortran/33941
* module.c (parse_atom): Parse also non-character
intrinsic operators.
2007-10-30 Dominique d'Humieres <dominiq@lps.ens.fr>
PR fortran/33941
* gfortran.dg/module_read_1.f90: New.
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c (Revision 129777)
+++ gcc/fortran/module.c (Arbeitskopie)
@@ -1195,6 +1195,11 @@ parse_atom (void)
case 'X':
case 'Y':
case 'Z':
+ /* For intrinsic operators such as /= or >=. */
+ case '=':
+ case '<':
+ case '>':
+ case '/':
parse_name (c);
return ATOM_NAME;
Index: gcc/testsuite/gfortran.dg/module_read_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/module_read_1.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/module_read_1.f90 (Revision 0)
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! PR fortran/33941
+! The problem was that the intrinsic operators
+! were written to the module file as '/=' etc.
+! but this format was not understood on reading.
+!
+! Test case by Toby White, stripped down by
+! Dominique d'Humieres
+
+module foo
+contains
+ function pop(n) result(item)
+ integer :: n
+ character(len=merge(0, 0, n > 0)) :: item
+ end function pop
+end module foo
+
+program test
+ use foo
+end program
+! { dg-final { cleanup-modules "foo" } }