Please find attached the promised patch, which bootstraps and regtests
on x86_64.

OK for trunk?

Paul

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

    * module.c : Add static no_module_procedures.
    (mio_symbol_attribute): Reset above if module procedure is
    encountered.
    (gfc_dump_module): Set above and exit without writing smod file
    if it reset.

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

    * gfortran.dg/public_private_module_5.f90: Add module procedure
    trigger_smod to ensure that the smod file is written.


On 9 September 2015 at 15:10, Paul Richard Thomas
<paul.richard.tho...@gmail.com> wrote:
> Dear FX,
>
> In other words, Intel behaves as my first implementation did, based on
> tests that Damian did for me, and that is what I have been pressing
> for.
>
> However, Reinhold's suggestion satisfies me completely. I obviously
> was tired when I read it because.... well, I don't know - it's obvious
> now.
>
> I'll get onto it right away. Expect a patch later on today.
>
> Best regards
>
> Paul
>
> On 9 September 2015 at 15:01, FX <fxcoud...@gmail.com> wrote:
>>> What happens if you add some private entities to the module? If that
>>> produces a points.smod, then I will finally shut up about the matter
>>> :-)
>>
>> No, if you add private entities to the module, still no smod file is 
>> generated, but the module file is changed.
>> Intel includes all private entities in the mod file. Recompilation will 
>> ensue if you change private entities. And while it is not perfect for some 
>> power users, it’s a minority of users.
>>
>> So, that being said: maybe we can default to do what Intel does, and have an 
>> option to generate dependency-friendly submodules?
>>
>> FX
>
>
>
Index: gcc/fortran/module.c
===================================================================
*** gcc/fortran/module.c        (revision 227527)
--- gcc/fortran/module.c        (working copy)
*************** static gzFile module_fp;
*** 193,198 ****
--- 193,203 ----
  static const char *module_name;
  /* The name of the .smod file that the submodule will write to.  */
  static const char *submodule_name;
+
+ /* Suppress the output of a .smod file by module, if no module
+    procedures have been seen.  */
+ static bool no_module_procedures;
+
  static gfc_use_list *module_list;

  /* If we're reading an intrinsic module, this is its ID.  */
*************** mio_symbol_attribute (symbol_attribute *
*** 2222,2228 ****
        if (attr->array_outer_dependency)
        MIO_NAME (ab_attribute) (AB_ARRAY_OUTER_DEPENDENCY, attr_bits);
        if (attr->module_procedure)
!       MIO_NAME (ab_attribute) (AB_MODULE_PROCEDURE, attr_bits);

        mio_rparen ();

--- 2227,2236 ----
        if (attr->array_outer_dependency)
        MIO_NAME (ab_attribute) (AB_ARRAY_OUTER_DEPENDENCY, attr_bits);
        if (attr->module_procedure)
!       {
!         MIO_NAME (ab_attribute) (AB_MODULE_PROCEDURE, attr_bits);
!         no_module_procedures = false;
!       }

        mio_rparen ();

*************** gfc_dump_module (const char *name, int d
*** 6071,6079 ****
    else
      dump_smod =false;

    dump_module (name, dump_flag);

!   if (dump_smod)
      return;

    /* Write a submodule file from a module.  The 'dump_smod' flag switches
--- 6079,6088 ----
    else
      dump_smod =false;

+   no_module_procedures = true;
    dump_module (name, dump_flag);

!   if (no_module_procedures || dump_smod)
      return;

    /* Write a submodule file from a module.  The 'dump_smod' flag switches
Index: gcc/testsuite/gfortran.dg/submodule_5.f08
===================================================================
*** gcc/testsuite/gfortran.dg/submodule_5.f08   (revision 227527)
--- gcc/testsuite/gfortran.dg/submodule_5.f08   (working copy)
*************** module foo_interface
*** 10,15 ****
--- 10,23 ----
    type foo
      character(len=16), private :: byebye = "adieu, world!   "
    end type foo
+
+ ! This interface is required to trigger the output of an .smod file.
+ ! See http://j3-fortran.org/doc/meeting/207/15-209.txt
+   interface
+     integer module function trigger_smod ()
+     end function
+   end interface
+
  end module

  module foo_interface_brother

Reply via email to