This is the mail archive of the gcc-patches@gcc.gnu.org mailing 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]

[Bug fortran/52846] [F2008] Support submodules - part 3/3


Dear All,

This is the third and final patch to implement submodules in gfortran.
It is the part that deals with private module entities. Unfortunately,
it is the most invasive and I would either like to have strong support
for it to be committed or a bright idea as to how to do it otherwise.

Since all the private entities in a module have to be transmitted to
their descendant submodules, whilst keeping them hidden from normal
use statements, I have chosen to write the module file as usual and
add a second part that contains the private entities. This latter is
only read when processing submodule statements.

I looked into encrypting the second part but could not find a way to
obtain the compression ratios that gzipping the module file affords,
largely from the repetition of attribute keywords. It was tempting to
reform completely the format of module files such that the symbol tree
is represented in binary format rather than in text. However, being
able to gunzip the files is very helpful from the diagnostic point of
view. Perhaps this is a suitable future upgrade for 6.0.0? That said,
I do not regard it as being high priority nor necessarily useful.

The other significant change is in respect of making module variable,
string length and procedure pointer declarations unconditionally
TREE_PUBLIC, whilst recycling the conditions to set DECL_VISIBILITY to
VISIBILITY_HIDDEN. This was a suggestion from Richard Biener, which
seems to do what is needed in libraries. This affects two existing
testcases: public_private_module_[2,6].f90, where xfails have been
added, where assembler symbols should be optimized away. These tests
can be removed if the above changes prove to be robust and acceptable
but I was reluctant to do this right away.

The rest of the patch is concerned with signaling to module.c that a
submodule statement is being processed.

It does cross my mind that all of this part of the submodule
implementation could be subject to the condition that a compiler
option is set. I am struck by the notion that making private module
entities available to submodules is an unnecessary complication and
that it amounts to be an error in the standard. This is why I am
suggesting the possibility of a specific compiler option.

The new testcase submodule_10.f08 is a near verbatim contribution from
Salvatore Filippone, for which thanks are due.

The remaining tasks are to try to fix PR66762, where submodule_6.f08
fails with -fto, and to update the documentation.

Bootstraps and regtests on FC21/x86_64 - OK for trunk?

Cheers

Paul

2015-07-23  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/52846
    * match.h : Add bool argument to gfc_use_modules so that it can
    signal to module.c that a submodule statement is being
    processed.
    * module.c (read_module): Add new module_locus, 'end_module'.
    Set it at the end of the public part of the module file. Then go
    there once the public part has been processed, ready to read
    the private part of the module file.
    (check_access): Change original to 'check_access1' and call it
    from 'check_access'. This latter inverts the result, according
    to whether or not static 'invert_access' is true.
    (gfc_dump_module): Write the public part of the module file as
    before and then follow it with the private part, obtained by
    setting 'invert_access' true. Once done, this is reset.
    (gfc_use_module): Read the public part of the module file. If
    this is a submodule and static 'submodule_stmt' is true, then
    read the private part. This permits the private part of module
    files to be respected with conventional use statements.
    (gfc_use_modules): 'submodule_stmt' set true if the ancestor
    module file is being used in processing submodule statement.
    * parse.c (use_modules): Introduce 'using_ancestor_modules' as
    a boolean argument. All calls set this argument false, except;
    (parse_module): Call use_modules with 'using_ancestor_modules'
    set true to signal the processing of a submodule statement.
    * trans-decl.c (gfc_finish_var_decl, gfc_build_qualified_array,
    get_proc_pointer_decl): Set TREE_PUBLIC unconditionally and use
    the conditions to set DECL_VISIBILITY as hidden and to set as
    true DECL_VISIBILITY_SPECIFIED.

2015-07-23  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/52846

    * gfortran.dg/public_private_module_2.f90: Add two XFAILS.
    * gfortran.dg/public_private_module_6.f90: Add an XFAIL.
    * gfortran.dg/submodule_10.f08: New test

Attachment: private_final.diff
Description: Text document


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