[Patch, fortran] PR63744 accept duplicate use-rename

Mikael Morin mikael.morin@sfr.fr
Fri Feb 6 20:32:00 GMT 2015


Hello,

we currently reject programs of the form
> 
> module m
>     integer :: s
> end module m
> subroutine s
>     use m, only: x => s, x => s
> end subroutine s

with an error stating that S is the name of the current program unit.
Interestingly, the duplicate rename is necessary to trigger it.

There doesn't seem to be a consensus as to whether it should be
accepted, but I think it should be.
Quoting Dominique's comment in the PR:
>  if
> 
>   use m, only: A => X
>   use m, only: B => X
> 
> is valid, I don't see why
> 
>   use m, only: A => X
>   use m, only: A => X
> 
> should not.
The problem is we check the original (symbol) name instead of the local
(symtree) name.
The fix is close to obvious, and should be safe for the branches (this
is a regression)
Regression tested on x86_64-linux. OK for trunk/4.9/4.8 ?

Mikael



-------------- next part --------------
2015-02-06  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/63744
	* module.c (check_for_ambiguous): Change argument type
	from gfc_symbol to gfc_symtree.  Check local (symtree) name
	instead of original (symbol) name.
	(read_module): Update caller.

2015-02-06  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/63744
	gfortran.dg/use_rename_8.f90: New.
	
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr63744.diff
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150206/9ed047b1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: use_rename_8.f90
Type: text/x-fortran
Size: 1119 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150206/9ed047b1/attachment-0001.bin>


More information about the Fortran mailing list