Bug 38171 - [regression] equivalence and nested modules broken
Summary: [regression] equivalence and nested modules broken
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P4 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-18 18:24 UTC by Scot Breitenfeld
Modified: 2008-11-19 16:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-11-18 20:26:48


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Scot Breitenfeld 2008-11-18 18:24:32 UTC
The following code worked for version 4.3 and 4.4 as of 9-28:

MODULE HDF5
  USE H5GLOBAL
END MODULE HDF5
MODULE H5GLOBAL
  IMPLICIT NONE
  INTEGER :: H5P_flags
  INTEGER :: H5P_DEFAULT_F
  EQUIVALENCE(H5P_flags, H5P_DEFAULT_F)
END MODULE H5GLOBAL
PROGRAM fortranlibtest
  USE HDF5
  IMPLICIT NONE
  INTEGER :: ii
  ii = H5P_DEFAULT_F 
END PROGRAM fortranlibtest


The current version of 4.4 and 4.3 (Nov. 11) fails to compile the code with the error:

gfortran43 H5f90global.o HDF5.o fortranlib_test.o -o test
fortranlib_test.o(.text+0x19): In function `MAIN__':
: undefined reference to `__h5global_MOD_h5p_default_f'
collect2: ld returned 1 exit status
*** Error code 1

4.2 compiles the code without a problem.

NOTE:

(1) If I remove the line
EQUIVALENCE(H5P_flags, H5P_DEFAULT_F)
it compiles fine.

(2) If I move the contents of H5GLOBAL into the HDF5 module i.e.

MODULE HDF5
  IMPLICIT NONE
  INTEGER :: H5P_flags
  INTEGER :: H5P_DEFAULT_F
  EQUIVALENCE(H5P_flags, H5P_DEFAULT_F)
END MODULE HDF5

it compiles fine.
Comment 1 kargls 2008-11-18 19:41:26 UTC
This is a regression that appears to be caused by

------------------------------------------------------------------------
r140879 | pault | 2008-10-04 22:50:00 -0700 (Sat, 04 Oct 2008) | 12 lines

2008-10-04  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/37706
        * module.c (load_equiv): Check the module before negating the
        unused flag.

Comment 2 Paul Thomas 2008-11-18 20:26:47 UTC
Ah, yes.  The module name check only pertains to the module being read. Instead, it should check that the equivalence members are from the same module - this might itself be use associated into the module being read.

Many thanks for the report.

Paul 
Comment 3 Paul Thomas 2008-11-19 03:43:41 UTC
Subject: Bug 38171

Author: pault
Date: Wed Nov 19 03:41:57 2008
New Revision: 141991

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141991
Log:
2008-11-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38171
	* ChangeLog: Correct PR number.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/testsuite/ChangeLog

Comment 4 Paul Thomas 2008-11-19 03:47:40 UTC
Subject: Bug 38171

Author: pault
Date: Wed Nov 19 03:46:12 2008
New Revision: 141992

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141992
Log:
2008-11-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38171
	* module.c (load_equiv): Regression fix; check that equivalence
	members come from the same module only.

2008-11-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38171
	* gfortran.dg/module_equivalence_6.f90: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/module_equivalence_6.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/module.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 5 Paul Thomas 2008-11-19 03:49:01 UTC
Fixed on trunk and 4.3.

Thanks for the report.

Paul
Comment 6 Dominique d'Humieres 2008-11-19 12:40:23 UTC
I don't know if the code in comment #0 is valid or not, but if the file h5global.mod does not exist compiling it with gfortran r141995 gives:

pr38171.f90:2.14:

  USE H5GLOBAL
             1
Fatal Error: Can't open module file 'h5global.mod' for reading at (1): No such file or directory

This error disappears if the module order is changed.

Comment 7 Paul Thomas 2008-11-19 16:21:37 UTC
(In reply to comment #6)
> I don't know if the code in comment #0 is valid or not, but if the file
> h5global.mod does not exist compiling it with gfortran r141995 gives:
> 
> pr38171.f90:2.14:
> 
>   USE H5GLOBAL
>              1
> Fatal Error: Can't open module file 'h5global.mod' for reading at (1): No such
> file or directory
>

Yes, the reporter had obviously already compiled the code so that the module was present:-)  It is correct when it's the right way round and it's pukka fortran.

Paul
> This error disappears if the module order is changed.
>