public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/63744] New: Duplicate use-statement causes error
@ 2014-11-05  8:46 roger.ferrer at bsc dot es
  2014-11-15 15:06 ` [Bug fortran/63744] [4.8/4.9/5 Regression] " dominiq at lps dot ens.fr
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: roger.ferrer at bsc dot es @ 2014-11-05  8:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

            Bug ID: 63744
           Summary: Duplicate use-statement causes error
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roger.ferrer at bsc dot es

Hi,

(I guess this is related to PR34657)

The following snippet is accepted by gfortran

-- test-ok.f90
MODULE MOO
    INTEGER :: S
END MODULE MOO

SUBROUTINE S1
    USE MOO, ONLY: X => S, X => S

    X = 1
END SUBROUTINE S1
-- end of test-ok.f90

but it is rejected if the program unit SUBROUTINE S1 is renamed to SUBROUTINE
S,
as shown below

-- test.f90
MODULE MOO
    INTEGER :: S
END MODULE MOO

SUBROUTINE S
    USE MOO, ONLY: X => S, X => S

    X = 1
END SUBROUTINE S
-- end of test.f90

$ gfortran -c test.f90
test.f90:6.8:

    USE MOO, ONLY: X => S, X => S
        1
Error: 's' of module 'moo', imported at (1), is also the name of the current
program unit
test.f90:8.5:

    X = 1
     1
Error: Name 'x' at (1) is an ambiguous reference to 's' from module 'moo'

Removing the second rename lets the code be accepted.

  USE MOO, ONLY: X => S

A similar behaviour is observed if we have two repeated USE-statements rather
than two repeated rename's in the rename-list

  USE MOO, ONLY: X => S
  USE MOO, ONLY: X => S

Kind regards,


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
@ 2014-11-15 15:06 ` dominiq at lps dot ens.fr
  2014-11-15 15:42 ` burnus at gcc dot gnu.org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-11-15 15:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.6.4
           Keywords|                            |rejects-valid
   Last reconfirmed|                            |2014-11-15
                 CC|                            |burnus@net-b.de
     Ever confirmed|0                           |1
            Summary|Duplicate use-statement     |[4.8/4.9/5 Regression]
                   |causes error                |Duplicate use-statement
                   |                            |causes error
      Known to fail|                            |4.6.4, 4.8.3, 4.9.2, 5.0

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The code is accepted by fortran 4.7.0 r176194 (2011-07-12) and rejected by
r176695 (2011-07-23) and above (up to trunk 5.0). I think it is r176375
(pr34657) where the error message has been introduced.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
  2014-11-15 15:06 ` [Bug fortran/63744] [4.8/4.9/5 Regression] " dominiq at lps dot ens.fr
@ 2014-11-15 15:42 ` burnus at gcc dot gnu.org
  2014-11-15 16:14 ` dominiq at lps dot ens.fr
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu.org @ 2014-11-15 15:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Dominque, as you changed:

- Status: UNCONFIRMED
+ Status: NEW
+ Keywords: rejects-valid 

Can you quote the standard which permits this? My feeling is that the code is
invalid, but I have to admit that it is only a feeling.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
  2014-11-15 15:06 ` [Bug fortran/63744] [4.8/4.9/5 Regression] " dominiq at lps dot ens.fr
  2014-11-15 15:42 ` burnus at gcc dot gnu.org
@ 2014-11-15 16:14 ` dominiq at lps dot ens.fr
  2014-11-15 17:00 ` burnus at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-11-15 16:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Can you quote the standard which permits this? My feeling is that the code
> is invalid, but I have to admit that it is only a feeling.

How do you read the following?

> 11.2.2 The USE statement and use association
> ...
> R1111 rename is local-name => use-name
> ...
> NOTE 11.9
> There is no prohibition against a use-name or use-defined-operator appearing
> multiple times in one USE statement or in multiple USE statements involving
> the same module. As a result, it is possible for one use-associated entity
> to be accessible by more than one local identier.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (2 preceding siblings ...)
  2014-11-15 16:14 ` dominiq at lps dot ens.fr
@ 2014-11-15 17:00 ` burnus at gcc dot gnu.org
  2014-11-15 17:04 ` dominiq at lps dot ens.fr
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu.org @ 2014-11-15 17:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|burnus@net-b.de             |

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #3)
> > 11.2.2 The USE statement and use association
> > ...
> > R1111 rename is local-name => use-name
> > ...
> > NOTE 11.9
> > There is no prohibition against a use-name or use-defined-operator appearing
> > multiple times in one USE statement or in multiple USE statements involving
> > the same module. As a result, it is possible for one use-associated entity
> > to be accessible by more than one local identier.

But that means things like:
  use m, only: A => X
  use m, only: B => X
which makes m's X (use-name) available under the names A and B (local-name).

In the case at hand, we have something more like:
  use m, only: A => X
  use m, only: A => Y
i.e. the LHS (local-name) is the same. In this example of mine A and A point to
a different object (X and Y), which is clearly ambiguous and invalid (at least
as soon as "A" is used). The question is whether it becomes valid if one uses:
  use m, only: A => X
  use m, only: A => X
i.e. the same object on the RHS.

The Fortran standard has:
"Within its scope, a local identifier of one class shall not be the same as
another local identifier of the same class, except that a generic name may be
the same as the name of a procedure as explained in 12.4.3.5 or the same as
the name of a derived type (4.5.10). A local identifier of one class may be the
same as a local identifier of another class." (F2015 draft, 14-007r2, 16.3.1)

And in the module section (11.2.2)
"Two or more accessible entities, other than generic interfaces or defined
operators, may have the same local identifier only if the identifier is not
used. Generic interfaces and defined operators are handled as described in
12.4.3.5. Except for these cases, the local identifier of any entity given
accessibility by a USE statement shall differ from the local identifiers of all
other entities accessible to the scoping unit."

I have to admit that I am unsure whether it is valid or not.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (3 preceding siblings ...)
  2014-11-15 17:00 ` burnus at gcc dot gnu.org
@ 2014-11-15 17:04 ` dominiq at lps dot ens.fr
  2014-11-19 13:28 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-11-15 17:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> I have to admit that I am unsure whether it is valid or not.

I share the same feeling, but 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.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (4 preceding siblings ...)
  2014-11-15 17:04 ` dominiq at lps dot ens.fr
@ 2014-11-19 13:28 ` rguenth at gcc dot gnu.org
  2014-11-20 11:36 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-11-19 13:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.8.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (5 preceding siblings ...)
  2014-11-19 13:28 ` rguenth at gcc dot gnu.org
@ 2014-11-20 11:36 ` jakub at gcc dot gnu.org
  2014-12-19 13:44 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-20 11:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |jakub at gcc dot gnu.org


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (6 preceding siblings ...)
  2014-11-20 11:36 ` jakub at gcc dot gnu.org
@ 2014-12-19 13:44 ` jakub at gcc dot gnu.org
  2015-02-03 14:49 ` mikael at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-19 13:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.4                       |4.8.5

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.4 has been released.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (7 preceding siblings ...)
  2014-12-19 13:44 ` jakub at gcc dot gnu.org
@ 2015-02-03 14:49 ` mikael at gcc dot gnu.org
  2015-02-06 20:01 ` mikael at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-02-03 14:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #7 from Mikael Morin <mikael at gcc dot gnu.org> ---
Created attachment 34658
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34658&action=edit
check the symtree (local) name instead of the original name

Here is a patch to accept it.

I think it makes sense to accept it; it's not ambiguous.
The current error message is at least confusing.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (8 preceding siblings ...)
  2015-02-03 14:49 ` mikael at gcc dot gnu.org
@ 2015-02-06 20:01 ` mikael at gcc dot gnu.org
  2015-02-08 14:18 ` mikael at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-02-06 20:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mikael at gcc dot gnu.org

--- Comment #8 from Mikael Morin <mikael at gcc dot gnu.org> ---
testing the patch


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (9 preceding siblings ...)
  2015-02-06 20:01 ` mikael at gcc dot gnu.org
@ 2015-02-08 14:18 ` mikael at gcc dot gnu.org
  2015-02-13 18:49 ` mikael at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-02-08 14:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

--- Comment #9 from Mikael Morin <mikael at gcc dot gnu.org> ---
Author: mikael
Date: Sun Feb  8 14:18:16 2015
New Revision: 220515

URL: https://gcc.gnu.org/viewcvs?rev=220515&root=gcc&view=rev
Log:

Use the local name instead of the original name in the check for name conflicts
between a hosting program unit and use-associated symbols
in that program unit.

fortran/
    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.

testsuite/
    PR fortran/63744
    gfortran.dg/use_rename_8.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/use_rename_8.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/module.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (10 preceding siblings ...)
  2015-02-08 14:18 ` mikael at gcc dot gnu.org
@ 2015-02-13 18:49 ` mikael at gcc dot gnu.org
  2015-02-13 19:34 ` mikael at gcc dot gnu.org
  2015-02-13 20:07 ` mikael at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-02-13 18:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

--- Comment #10 from Mikael Morin <mikael at gcc dot gnu.org> ---
Author: mikael
Date: Fri Feb 13 18:48:35 2015
New Revision: 220690

URL: https://gcc.gnu.org/viewcvs?rev=220690&root=gcc&view=rev
Log:

Use the local name instead of the original name in the check for name conflicts
between a hosting program unit and use-associated symbols
in that program unit.

fortran/
    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.

testsuite/
    PR fortran/63744
    gfortran.dg/use_rename_8.f90: New.


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (11 preceding siblings ...)
  2015-02-13 18:49 ` mikael at gcc dot gnu.org
@ 2015-02-13 19:34 ` mikael at gcc dot gnu.org
  2015-02-13 20:07 ` mikael at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-02-13 19:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

--- Comment #11 from Mikael Morin <mikael at gcc dot gnu.org> ---
Author: mikael
Date: Fri Feb 13 19:33:27 2015
New Revision: 220692

URL: https://gcc.gnu.org/viewcvs?rev=220692&root=gcc&view=rev
Log:

Use the local name instead of the original name in the check for name conflicts
between a hosting program unit and use-associated symbols
in that program unit.

fortran/
    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.

testsuite/
    PR fortran/63744
    gfortran.dg/use_rename_8.f90: New.



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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/63744] [4.8/4.9/5 Regression] Duplicate use-statement causes error
  2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
                   ` (12 preceding siblings ...)
  2015-02-13 19:34 ` mikael at gcc dot gnu.org
@ 2015-02-13 20:07 ` mikael at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-02-13 20:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63744

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #12 from Mikael Morin <mikael at gcc dot gnu.org> ---
Fixed for versions 5.0, 4.9.3, 4.8.5
Closing.
Thanks for the report.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-02-13 20:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-05  8:46 [Bug fortran/63744] New: Duplicate use-statement causes error roger.ferrer at bsc dot es
2014-11-15 15:06 ` [Bug fortran/63744] [4.8/4.9/5 Regression] " dominiq at lps dot ens.fr
2014-11-15 15:42 ` burnus at gcc dot gnu.org
2014-11-15 16:14 ` dominiq at lps dot ens.fr
2014-11-15 17:00 ` burnus at gcc dot gnu.org
2014-11-15 17:04 ` dominiq at lps dot ens.fr
2014-11-19 13:28 ` rguenth at gcc dot gnu.org
2014-11-20 11:36 ` jakub at gcc dot gnu.org
2014-12-19 13:44 ` jakub at gcc dot gnu.org
2015-02-03 14:49 ` mikael at gcc dot gnu.org
2015-02-06 20:01 ` mikael at gcc dot gnu.org
2015-02-08 14:18 ` mikael at gcc dot gnu.org
2015-02-13 18:49 ` mikael at gcc dot gnu.org
2015-02-13 19:34 ` mikael at gcc dot gnu.org
2015-02-13 20:07 ` mikael at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).