[gfortran] patch: fix COMMON vars in module

Steve Kargl sgk@troutmask.apl.washington.edu
Sat Jul 10 23:46:00 GMT 2004


On Sun, Jul 11, 2004 at 12:36:22AM +0100, Paul Brook wrote:
> > This two-line patch fixes this, built and tested on i686-pc-linux.
> > Testcase is also ready for adding to the testsuite.
> >
> > - Tobi
> >
> > 2004-07-10  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
> >
> > 	* trans-decl.c (gfc_create_module_variable): Nothing to do if
> > 	symbol is in common, because we ...
> > 	(gfc_generate_module_vars): Call gfc_trans_common.
> 
> Ok, after you fix the testcase:)
> 

Are you sure it is suppose to compile?  Here's Tobi's original
code:

MODULE m
 common /c/x
contains
 subroutine b()
   x = 1.
 end
end

common /c/x
x = 2.
call b()
print *, x
end

kargl[211] f95 -o a a.f90
Error: a.f90, line 6: syntax error
       detected at END@<end-of-statement>
[f95 terminated - errors found by pass 1]

Okay fix the CONTAIN subroutine by
 subroutine b()
   x = 1.
 end subroutine b

kargl[212] f95 -o a a.f90
a.o: In function `main':
a.o(.text+0x3c): undefined reference to `b_'

Finally, USE the module by adding "USE m" above the main program.

kargl[213] f95 -o a a.f90
Error: a.f90, line 10: Redeclaration of symbol X from USEd module
       detected at /@X
Error: a.f90, line 10: X is already in COMMON/C/
       detected at X@<end-of-statement>
[f95 terminated - errors found by pass 1]



-- 
Steve



More information about the Fortran mailing list