From ccd7751b3424a4e5082a57341789649bc495f0c6 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Wed, 19 Mar 2014 22:03:14 +0100 Subject: re PR fortran/60543 (Function with side effect removed by the optimizer.) 2014-03-18 Tobias Burnus PR fortran/60543 PR fortran/60283 * gfortran.h (gfc_unset_implicit_pure): New prototype. * resolve.c (gfc_unset_implicit_pure): New. (resolve_structure_cons, resolve_function, pure_subroutine): Use it. * decl.c (match_old_style_init, gfc_match_data, match_pointer_init, variable_decl): Ditto. * expr.c (gfc_check_pointer_assign): Ditto. * intrinsic.c (gfc_intrinsic_sub_interface): Ditto. * io.c (match_vtag, gfc_match_open, gfc_match_close, match_filepos, gfc_match_inquire, gfc_match_print, gfc_match_wait): Ditto. * match.c (gfc_match_critical, gfc_match_stopcode, lock_unlock_statement, sync_statement, gfc_match_allocate, gfc_match_deallocate): Ditto. * parse.c (decode_omp_directive): Ditto. * symbol.c (gfc_add_save): Ditto. 2014-03-18 Tobias Burnus PR fortran/60543 PR fortran/60283 * gfortran.dg/implicit_pure_4.f90: New. From-SVN: r208687 --- gcc/fortran/decl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gcc/fortran/decl.c') diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 2d405fe..4048ac9 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -510,9 +510,7 @@ match_old_style_init (const char *name) free (newdata); return MATCH_ERROR; } - - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (gfc_current_ns->proc_name); /* Mark the variable as having appeared in a data statement. */ if (!gfc_add_data (&sym->attr, sym->name, &sym->declared_at)) @@ -571,9 +569,7 @@ gfc_match_data (void) gfc_error ("DATA statement at %C is not allowed in a PURE procedure"); return MATCH_ERROR; } - - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (gfc_current_ns->proc_name); return MATCH_YES; @@ -1739,6 +1735,7 @@ match_pointer_init (gfc_expr **init, int procptr) "a PURE procedure"); return MATCH_ERROR; } + gfc_unset_implicit_pure (gfc_current_ns->proc_name); /* Match NULL() initialization. */ m = gfc_match_null (init); @@ -2046,6 +2043,10 @@ variable_decl (int elem) m = MATCH_ERROR; } + if (current_attr.flavor != FL_PARAMETER + && gfc_state_stack->state != COMP_DERIVED) + gfc_unset_implicit_pure (gfc_current_ns->proc_name); + if (m != MATCH_YES) goto cleanup; } -- cgit v1.1