Tobias Burnus - [Patch, Fortran] PR30973, disallow to reuse a module name or to use the (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

:ADDPATCH fortran:

As Daniel Franke found out, the following gives no error:

PROGRAM test_foo USE foo, ONLY: x INTEGER :: foo foo = 1 END PROGRAM

as the module name does not get imported as symbol as soon as "ONLY:" is specified (incl. zero symbols after only).

In addition, using USE mymod, only: mymod is possible as is USE mymod, only: foo => mymod and USE mymod, only: mymod => foo

The first two plainly make no sense. The third one has ambiguity problems.

Tobias

2007-02-27 Tobias Burnus burnus@net-b.de

PR fortran/30973
* module.c (read_module): Always import module name as symbol.
(gfc_match_use): Disallow module name in the only clause of
a use statement.

2007-02-27 Tobias Burnus burnus@net-b.de

PR fortran/30973
* gfortran.dg/use_4.f90: New test.

Index: gcc/fortran/module.c

*** gcc/fortran/module.c (revision 122377) --- gcc/fortran/module.c (working copy) *************** gfc_match_use (void) *** 619,624 **** --- 619,632 ---- goto cleanup; }
+ if (strcmp (new->use_name, module_name) == 0 + || strcmp (new->local_name, module_name) == 0) + { + gfc_error ("The name '%s' at %C has already been used as " + "an external module name.", module_name); + goto cleanup; + } + break;
case INTERFACE_USER_OP: *************** read_module (void) *** 3438,3443 **** --- 3446,3454 ---- /* Get the jth local name for this symbol. / p = find_use_name_n (name, &j);
+ if (p == NULL && strcmp (name, module_name) == 0) + p = name; + /
Skip symtree nodes not in an ONLY clause, unless there is an existing symtree loaded from another USE statement. */ Index: gcc/testsuite/gfortran.dg/use_4.f90

*** gcc/testsuite/gfortran.dg/use_4.f90 (revision 0) --- gcc/testsuite/gfortran.dg/use_4.f90 (revision 0)


*** 0 **** --- 1,33 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]