aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/parse.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2020-07-19 12:23:43 +0200
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:18:31 -0300
commite6db6dfee24bf10e603237273e541594bd360a56 (patch)
tree3f00715fb81b1891319c465e7cfadf568b712b3e /gcc/fortran/parse.c
parent7c70bb56eb88fc7a48c91ec1031651139a7d054d (diff)
downloadgcc-e6db6dfee24bf10e603237273e541594bd360a56.zip
gcc-e6db6dfee24bf10e603237273e541594bd360a56.tar.gz
gcc-e6db6dfee24bf10e603237273e541594bd360a56.tar.bz2
Fix handling of implicit_pure by checking if non-pure procedures are called.
Procedures are marked as implicit_pure if they fulfill the criteria of pure procedures. In this case, a procedure was not marked as not being implicit_pure which called another procedure, which had not yet been marked as not being implicit_impure. Fixed by iterating over all procedures, setting callers of procedures which are non-pure and non-implicit_pure as non-implicit_pure and doing this until no more procedure has been changed. gcc/fortran/ChangeLog: 2020-07-19 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/96018 * frontend-passes.c (gfc_check_externals): Adjust formatting. (implicit_pure_call): New function. (implicit_pure_expr): New function. (gfc_fix_implicit_pure): New function. * gfortran.h (gfc_fix_implicit_pure): New prototype. * parse.c (translate_all_program_units): Call gfc_fix_implicit_pure.
Diffstat (limited to 'gcc/fortran/parse.c')
-rw-r--r--gcc/fortran/parse.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 3671513..d30208f 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -6447,6 +6447,11 @@ loop:
gfc_resolve (gfc_current_ns);
+ /* Fix the implicit_pure attribute for those procedures who should
+ not have it. */
+ while (gfc_fix_implicit_pure (gfc_current_ns))
+ ;
+
/* Dump the parse tree if requested. */
if (flag_dump_fortran_original)
gfc_dump_parse_tree (gfc_current_ns, stdout);
@@ -6492,6 +6497,23 @@ done:
/* Do the resolution. */
resolve_all_program_units (gfc_global_ns_list);
+ /* Go through all top-level namespaces and unset the implicit_pure
+ attribute for any procedures that call something not pure or
+ implicit_pure. Because the a procedure marked as not implicit_pure
+ in one sweep may be called by another routine, we repeat this
+ process until there are no more changes. */
+ bool changed;
+ do
+ {
+ changed = false;
+ for (gfc_current_ns = gfc_global_ns_list; gfc_current_ns;
+ gfc_current_ns = gfc_current_ns->sibling)
+ {
+ if (gfc_fix_implicit_pure (gfc_current_ns))
+ changed = true;
+ }
+ }
+ while (changed);
/* Fixup for external procedures. */
for (gfc_current_ns = gfc_global_ns_list; gfc_current_ns;