[PATCH] PR fortran/82992 -- Check for conflicting symbols

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] PR fortran/82992 -- Check for conflicting symbols

Steve Kargl
The attached patch has be regression tested on x86_64-*-freebsd.

The testcase in the PR explains what the patch does.

% cat z1.f90
subroutine sub (x)
   use iso_fortran_env, only: x => character_kinds
end
%  gfcx -c a.f90
a.f90:1:17:

    1 | subroutine sub (x)
      |                 1
    2 |    use iso_fortran_env, only: x => character_kinds
      |                               2
Error: Symbol 'x' at (1) conflicts with the rename symbol at (2)

OK to commit?

2019-08-15  Steven G. Kargl  <[hidden email]>

 PR fortran/82992
 * module.c (gfc_match_use):  When renaming a module entity, search
 current namespace for conflicting symbol.

2019-08-15  Steven G. Kargl  <[hidden email]>

 PR fortran/82992
 * gfortran.dg/pr71649.f90: Adjust error messages.
 * gfortran.dg/use_15.f90: Ditto.
 * gfortran.dg/use_rename_8.f90: Ditto.

--
Steve

pr82992.diff (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/82992 -- Check for conflicting symbols

Harald Anlauf-3
Hi Steve,

it appears that your patch leads to error messages pointing to
a rename where there is none.  Is there a way to avoid this?

E.g.

 ! PR71649 Internal Compiler Error
-SUBROUTINE Compiler_Options ( Options, Version, WriteOpt )
-   USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! {
dg-error "already declared" }
+SUBROUTINE Compiler_Options ( Options, Version, WriteOpt )        ! {
dg-error "\(1\)" }
+   USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! {
dg-error "conflicts with the rename" }

or

-SUBROUTINE C
-    USE MOO, ONLY: C  ! { dg-error "is also the name of the current
program unit" }
+SUBROUTINE C          ! { dg-error "\(1\)" }
+    USE MOO, ONLY: C  ! { dg-error "conflicts with the rename" }
 END SUBROUTINE C

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/82992 -- Check for conflicting symbols

Steve Kargl
On Fri, Aug 16, 2019 at 09:24:31PM +0200, Harald Anlauf wrote:

> Hi Steve,
>
> it appears that your patch leads to error messages pointing to
> a rename where there is none.  Is there a way to avoid this?
>
> E.g.
>
>  ! PR71649 Internal Compiler Error
> -SUBROUTINE Compiler_Options ( Options, Version, WriteOpt )
> -   USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! {
> dg-error "already declared" }
> +SUBROUTINE Compiler_Options ( Options, Version, WriteOpt )        ! {
> dg-error "\(1\)" }
> +   USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! {
> dg-error "conflicts with the rename" }
>
> or
>
> -SUBROUTINE C
> -    USE MOO, ONLY: C  ! { dg-error "is also the name of the current
> program unit" }
> +SUBROUTINE C          ! { dg-error "\(1\)" }
> +    USE MOO, ONLY: C  ! { dg-error "conflicts with the rename" }
>  END SUBROUTINE C

I don't understand what you are trying to show with this diff.

--
Steve
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/82992 -- Check for conflicting symbols

Steve Kargl
On Fri, Aug 16, 2019 at 12:27:36PM -0700, Steve Kargl wrote:
> On Fri, Aug 16, 2019 at 09:24:31PM +0200, Harald Anlauf wrote:
> > Hi Steve,
> >
> > it appears that your patch leads to error messages pointing to
> > a rename where there is none.  Is there a way to avoid this?
> >

Yes.

--
Steve
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/82992 -- Check for conflicting symbols

Harald Anlauf-3
In reply to this post by Steve Kargl
On 08/16/19 21:27, Steve Kargl wrote:

> On Fri, Aug 16, 2019 at 09:24:31PM +0200, Harald Anlauf wrote:
>> Hi Steve,
>>
>> it appears that your patch leads to error messages pointing to
>> a rename where there is none.  Is there a way to avoid this?
>>
>> E.g.
>>
>>  ! PR71649 Internal Compiler Error
>> -SUBROUTINE Compiler_Options ( Options, Version, WriteOpt )
>> -   USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! {
>> dg-error "already declared" }
>> +SUBROUTINE Compiler_Options ( Options, Version, WriteOpt )        ! {
>> dg-error "\(1\)" }
>> +   USE ISO_FORTRAN_ENV, ONLY : Compiler_Version, Compiler_Options ! {
>> dg-error "conflicts with the rename" }
>>
>> or
>>
>> -SUBROUTINE C
>> -    USE MOO, ONLY: C  ! { dg-error "is also the name of the current
>> program unit" }
>> +SUBROUTINE C          ! { dg-error "\(1\)" }
>> +    USE MOO, ONLY: C  ! { dg-error "conflicts with the rename" }
>>  END SUBROUTINE C
>
> I don't understand what you are trying to show with this diff.
>

This was a truncated quote from your diff.
What I was trying to say is that the new error message is misleading.

USE, foo, ONLY : bar
does not rename bar.

Harald

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/82992 -- Check for conflicting symbols

Steve Kargl
On Fri, Aug 16, 2019 at 09:33:32PM +0200, Harald Anlauf wrote:

> On 08/16/19 21:27, Steve Kargl wrote:
> > On Fri, Aug 16, 2019 at 09:24:31PM +0200, Harald Anlauf wrote:
> >> Hi Steve,
> >>
> >> it appears that your patch leads to error messages pointing to
> >> a rename where there is none.  Is there a way to avoid this?
> >>
> >
> > I don't understand what you are trying to show with this diff.
> >
>
> This was a truncated quote from your diff.
> What I was trying to say is that the new error message is misleading.
>
> USE, foo, ONLY : bar
> does not rename bar.
>
New diff attached.

--
Steve

pr82992.diff (4K) Download Attachment