* [Bug fortran/53940] warn about duplicate USE
2012-07-12 12:33 [Bug fortran/53940] New: warn about duplicate USE Bil.Kleb at NASA dot gov
@ 2012-07-12 13:09 ` burnus at gcc dot gnu.org
2012-07-12 13:25 ` Bil.Kleb at NASA dot gov
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-07-12 13:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53940
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-07-12 13:08:51 UTC ---
(In reply to comment #0)
> The old DEC Alpha compiler does:
[...]
> f90: Error: duplicate_use.f90, line 8: The same named entity from different
> modules and/or program units cannot be referenced. [VAR]
> print*, var
> ----------^
That that one is completely bogus. The standard allows multiple inclusion of
the same variable; and your variable is - contrary to the error message - from
the same module. For instance, the following is valid:
use mod
use mod, var2 => var
That way one has use-associated the variable "var" under the name "var" and
under the name "var2".
The Fortran standard (here: Fortran 2008, "11.2.2 The USE statement and use
association") has:
"More than one USE statement for a given module may appear in a specification
part. If one of the USE statements is without an ONLY option, all public
entities in the module are accessible. If all the USE statements have ONLY
options, only those entities in one or more of the only-lists are accessible.
"An accessible entity in the referenced module has one or more local
identifiers. [...]" (Cf. http://gcc.gnu.org/wiki/GFortranStandards)
Hence, I am inclined to reject the warning proposal. (The request to print an
error is simply invalid.)
However, if you can give a good argument why you want to have a special warning
and when it exactly should be triggered, one could consider it. However, I
currently fail to see a real use case for that.
Note: module entities which have been explicitly use associated but aren't used
are warned for. Thus, one could consider to warn if the same entity under the
same name is multiple times use associated. However, that's not only valid but
seems to be also harmless and a rather special case.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/53940] warn about duplicate USE
2012-07-12 12:33 [Bug fortran/53940] New: warn about duplicate USE Bil.Kleb at NASA dot gov
2012-07-12 13:09 ` [Bug fortran/53940] " burnus at gcc dot gnu.org
@ 2012-07-12 13:25 ` Bil.Kleb at NASA dot gov
2012-07-12 13:45 ` [Bug fortran/53940] Optionally warn about multiple explicit USE-association of the same symbol burnus at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Bil.Kleb at NASA dot gov @ 2012-07-12 13:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53940
--- Comment #2 from Bil Kleb <Bil.Kleb at NASA dot gov> 2012-07-12 13:25:29 UTC ---
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 ! should produce at least a warning?
var = 1
print*, var
end program
EOF
% gfortran duplicate_declaration.f90
duplicate_declaration.f90:3.16:
integer :: var ! should produce at least a warning?
1
Error: Symbol 'var' at (1) already has basic type of INTEGER
While the error is mostly harmless, we find it useful to know about to keep our
code clean.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/53940] Optionally warn about multiple explicit USE-association of the same symbol
2012-07-12 12:33 [Bug fortran/53940] New: warn about duplicate USE Bil.Kleb at NASA dot gov
2012-07-12 13:09 ` [Bug fortran/53940] " burnus at gcc dot gnu.org
2012-07-12 13:25 ` Bil.Kleb at NASA dot gov
@ 2012-07-12 13:45 ` burnus at gcc dot gnu.org
2014-05-19 16:03 ` Joost.VandeVondele at mat dot ethz.ch
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-07-12 13:45 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/53940] Optionally warn about multiple explicit USE-association of the same symbol
2012-07-12 12:33 [Bug fortran/53940] New: warn about duplicate USE Bil.Kleb at NASA dot gov
` (2 preceding siblings ...)
2012-07-12 13:45 ` [Bug fortran/53940] Optionally warn about multiple explicit USE-association of the same symbol burnus at gcc dot gnu.org
@ 2014-05-19 16:03 ` Joost.VandeVondele at mat dot ethz.ch
2015-10-13 16:28 ` dominiq at lps dot ens.fr
2020-07-30 15:37 ` dominiq at lps dot ens.fr
5 siblings, 0 replies; 7+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2014-05-19 16:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53940
Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Joost.VandeVondele at mat dot ethz
| |.ch
--- Comment #4 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> ---
still useful.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/53940] Optionally warn about multiple explicit USE-association of the same symbol
2012-07-12 12:33 [Bug fortran/53940] New: warn about duplicate USE Bil.Kleb at NASA dot gov
` (3 preceding siblings ...)
2014-05-19 16:03 ` Joost.VandeVondele at mat dot ethz.ch
@ 2015-10-13 16:28 ` dominiq at lps dot ens.fr
2020-07-30 15:37 ` dominiq at lps dot ens.fr
5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-13 16:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53940
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-10-13
Ever confirmed|0 |1
--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
No warning at r228753.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/53940] Optionally warn about multiple explicit USE-association of the same symbol
2012-07-12 12:33 [Bug fortran/53940] New: warn about duplicate USE Bil.Kleb at NASA dot gov
` (4 preceding siblings ...)
2015-10-13 16:28 ` dominiq at lps dot ens.fr
@ 2020-07-30 15:37 ` dominiq at lps dot ens.fr
5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-07-30 15:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53940
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |WONTFIX
--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Closing.
^ permalink raw reply [flat|nested] 7+ messages in thread