This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/33541] New: gfortran wrongly imports renamed-use-associated symbol unrenamed
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Sep 2007 08:44:59 -0000
- Subject: [Bug fortran/33541] New: gfortran wrongly imports renamed-use-associated symbol unrenamed
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Reported by John Harper,
http://gcc.gnu.org/ml/fortran/2007-09/msg00397.html
The following
use module
use module, only: xrenamed => x
surely makes xrenamed available; however, -- see clause (3) below -- it does
not make 'x' available. In gfortran the symbol 'x' is also imported into the
namespace.
The Fortran 2003 standard contains (11.2.1):
More than one USE statement for a given module may appear in
a scoping unit. If one of the USE statements is without an
ONLY qualifier, all public entities in the module are accessible.
If all the USE statements have ONLY qualifiers, only those
entities named in one or more of the only-lists are accessible.
however, this is followed by the following restrictions:
An accessible entity in the referenced module has one or more
local identifiers. These identifiers are
(1) The identifier of the entity in the referenced module if
that identifier appears as an only use-name or as the
defined-operator of a generic-spec in any only for that module,
(2) Each of the local-names or local-defined-operators that the
entity is given in any rename for that module, and
(3) The identifier of the entity in the referenced module if
that identifier does not appear as a use-name or
use-defined-operator in any rename for that module.
For 'x' case 3 applies (or better it does not apply) and thus 'x' shall not be
imported.
Example by John Harper (ifort, sunf95, NAG f95 and openf95 properly print
.FALSE., gfortran prints .TRUE.):
MODULE xmod
REAL(kind(1d0)) :: x = -666
END MODULE xmod
PROGRAM test2uses
USE xmod
USE xmod, ONLY: xrenamed => x ! kind(1d0)
x = 666 ! kind(1.0): see below
PRINT *,'kind(xrenamed)==kind(x)?',kind(xrenamed)==kind(x)
PRINT *,'That should have printed',.FALSE.
END PROGRAM test2uses
--
Summary: gfortran wrongly imports renamed-use-associated symbol
unrenamed
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33541