Bug 29464 - [4.1 only] problem with duplicate USE, ONLY of procedure in INTERFACE
Summary: [4.1 only] problem with duplicate USE, ONLY of procedure in INTERFACE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 minor
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords:
Depends on:
Blocks: 29670
  Show dependency treegraph
 
Reported: 2006-10-13 18:17 UTC by Vivek Rao
Modified: 2006-12-21 14:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-12-04 09:44:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vivek Rao 2006-10-13 18:17:51 UTC
For the program

module foo_mod
implicit none
interface twice
   module procedure twice_real
end interface twice
contains
real function twice_real(x)
real :: x
twice_real = 2*x
end function twice_real
end module foo_mod

program xfoo
use foo_mod, only: twice,twice
implicit none
print*,twice(2.3)
end program xfoo

version gcc version 4.2.0 20061011 (experimental)
of gfortran on Windows XP says

 In file xduplicate_use.f90:14

use foo_mod, only: twice,twice
                        1
Error: Symbol 'twice' referenced at (1) not found in
module 'foo_mod'

In the thread "USE, ONLY question" in
comp.lang.fortran, most people thought that repetition
in a USE, ONLY statement was standard-conforming.

If "twice" is replaced with "twice_real" in program
xfoo, it compiles and runs, giving the expected
output.

Vivek Rao
Comment 1 Paul Thomas 2006-10-15 07:02:15 UTC
(In reply to comment #0)

More seriously, this is also broken.

module foo_mod
implicit none
interface twice
   module procedure twice_real
end interface twice
contains
real function twice_real(x)
real :: x
twice_real = 2*x
end function twice_real
end module foo_mod

program xfoo
use foo_mod, only: two=>twice,dbl=>twice
implicit none
print*,two(2.3)
print*,dbl(2.3)
end program xfoo

Paul
Comment 2 patchapp@dberlin.org 2006-11-25 15:05:27 UTC
Subject: Bug number PR29464

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-11/msg01705.html
Comment 3 Paul Thomas 2006-12-04 09:44:08 UTC
Since I posted a fix, I guess that I should accept the bug!

Paul
Comment 4 Paul Thomas 2006-12-09 20:52:39 UTC
Subject: Bug 29464

Author: pault
Date: Sat Dec  9 20:52:27 2006
New Revision: 119696

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

	PR fortran/29464
	* module.c (load_generic_interfaces): Add symbols for all the
	local names of an interface.  Share the interface amongst the
	symbols.
	* gfortran.h : Add generic_copy to symbol_attribute.
	* symbol.c (free_symbol): Only free interface if generic_copy
	is not set.

2006-11-25  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29464
	* gfortran.dg/module_interface_2.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/module_interface_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Paul Thomas 2006-12-21 14:19:57 UTC
Subject: Bug 29464

Author: pault
Date: Thu Dec 21 14:19:40 2006
New Revision: 120110

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

	PR fortran/29464
	* module.c (load_generic_interfaces): Add symbols for all the
	local names of an interface.  Share the interface amongst the
	symbols.
	* gfortran.h : Add generic_copy to symbol_attribute.
	* symbol.c (free_symbol): Only free interface if generic_copy
	is not set.

2006-11-21  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29464
	* gfortran.dg/module_interface_2.f90: New test.


Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/module_interface_2.f90
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/gfortran.h
    branches/gcc-4_2-branch/gcc/fortran/module.c
    branches/gcc-4_2-branch/gcc/fortran/symbol.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 6 Paul Thomas 2006-12-21 14:56:12 UTC
Fixed on trunk and 4.2

Paul