This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/53940] Optionally warn about multiple explicit USE-association of the same symbol
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 12 Jul 2012 13:44:55 +0000
- Subject: [Bug fortran/53940] Optionally warn about multiple explicit USE-association of the same symbol
- Auto-submitted: auto-generated
- References: <bug-53940-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53940
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Summary|warn about duplicate USE |Optionally warn about
| |multiple explicit
| |USE-association of the same
| |symbol
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-07-12 13:44:55 UTC ---
(In reply to comment #2)
> I guess I see the USE ONLY as similar to a declaration, and to have two of the
> same declarations in a program is an error, e.g.,
> $ cat duplicate_declaration.f90 << EOF
> program duplicate_declaration
> integer :: var
> integer :: var
Well, here you declare two different variables with the same name. In the
original example, you use associate the same variable under the same name.
Thus, technically, this example is invalid while the first one is valid.
(At least that's how I understand the Fortran standard.)
However, I concur that one could warn if the same variable appears multiple
times in a "USE ..., ONLY:" either as you had:
use mod, only: var
use mod, only: var
or as in
use mod, only: var, var
Both are perfectly valid, but I concur that (in well written code) it should
not occur. I don't think we want to warn for:
use mod
use mod, only: var
which also (kind of) use-associates "var" multiple times.
The warning implementation should be doable somewhere in the depths of module.c
as we only set "sym->attr.use_only" for explicitly use-associated symbols.