diff options
author | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-17 09:09:34 +0000 |
---|---|---|
committer | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-17 09:09:34 +0000 |
commit | 32c2c7e7511f862990dc12a733df1f85ba738e1e (patch) | |
tree | a7c286c611bf842796a367c55951cec6af9a1761 /gcc/fortran/module.c | |
parent | 452511fe89b8cb0201586c1fe50ceb83682ca558 (diff) |
2015-09-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/52846
PR fortran/67588
* module.c : Add static no_module_procedures.
(gfc_match_submodule): Correct memory leakage caused during the
freeing of use_lists.
(mio_symbol_attribute): Reset above if module procedure is
encountered.
(gfc_dump_module): Set above and exit without writing smod file
if it reset.
* gfortran.texi : Add section on submodule support.
2015-09-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/52846
* gfortran.dg/public_private_module_5.f90: Add module procedure
trigger_smod to ensure that the smod file is written.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227855 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/module.c')
-rw-r--r-- | gcc/fortran/module.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index d88969e7d5d2..f0d84a486124 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -193,6 +193,11 @@ static gzFile module_fp; 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. */ @@ -798,7 +803,7 @@ gfc_match_submodule (void) /* Just retain the ultimate .(s)mod file for reading, since it contains all the information in its ancestors. */ use_list = module_list; - for (; module_list->next; use_list = use_list->next) + for (; module_list->next; use_list = module_list) { module_list = use_list->next; free (use_list); @@ -2222,7 +2227,10 @@ mio_symbol_attribute (symbol_attribute *attr) 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 (); @@ -6081,9 +6089,10 @@ gfc_dump_module (const char *name, int dump_flag) else dump_smod =false; + no_module_procedures = true; dump_module (name, dump_flag); - if (dump_smod) + if (no_module_procedures || dump_smod) return; /* Write a submodule file from a module. The 'dump_smod' flag switches |