[Patch, fortran] PR20863 and PR20082 - things PURE and impure

Jerry DeLisle jvdelisle@verizon.net
Sun Jun 17 21:40:00 GMT 2007


See comments below ---
Paul Thomas wrote:
> :ADDPATCH fortran:
> 
> These might be said to be legacy PRs:)  Seriously, though, getting the 
> constraints right for PURE procedures is important and it is a shame 
> that these have lain around for so long.
> 
> The patch remedies two omissions in applying the constraints associated 
> with variables in PURE procedures.  The testcase lifts the reporters' 
> originals and exercises the fix a bit more.  The patch and the Changelog 
> pretty much speak for themselves.
> 
> Bootstrapped and regtested on x86_ia64/FC5 - OK for trunk and 4.2?
> 
> Paul
> 
> 2007-06-16  Paul Thomas  <pault@gcc.gnu.org>
> 
>    PR fortran/20863
>    PR fortran/20082
>    * resolve.c (resolve_code): Use gfc_impure_variable as a
>    condition for rejecting derived types with pointers, in pure
>    procedures.
>    (gfc_impure_variable): Add test for dummy arguments of pure
>    procedures; any for functions and INTENT_IN for subroutines.
> 
> 2007-06-16  Paul Thomas  <pault@gcc.gnu.org>
> 
>    PR fortran/20863
>    PR fortran/20082
>    * gfortran.dg/impure_assignment_2.f90 : New test.
> 
> 
> ------------------------------------------------------------------------
> 
> Index: gcc/fortran/resolve.c
> ===================================================================
> *** gcc/fortran/resolve.c	(revision 125756)
> --- gcc/fortran/resolve.c	(working copy)
> *************** resolve_code (gfc_code *code, gfc_namesp
> *** 5267,5282 ****
>   		}
>   
>   	      if (code->expr2->ts.type == BT_DERIVED
> ! 		  && derived_pointer (code->expr2->ts.derived))
>   		{
> ! 		  gfc_error ("Right side of assignment at %L is a derived "
> ! 			     "type containing a POINTER in a PURE procedure",
>   			     &code->expr2->where);
>   		  break;
>   		}
>   	    }
>   
> ! 	  gfc_check_assign (code->expr, code->expr2, 1);
>   	  break;
>   
>   	case EXEC_LABEL_ASSIGN:
> --- 5267,5285 ----
>   		}
>   
>   	      if (code->expr2->ts.type == BT_DERIVED
> ! 		    && code->expr2->expr_type == EXPR_VARIABLE
> ! 		    && gfc_impure_variable (code->expr2->symtree->n.sym)
> ! 		    && derived_pointer (code->expr2->ts.derived))
>   		{
> ! 		  gfc_error ("Right side of assignment at %L is an impure "
> ! 			     "derived type variable with a POINTER "
> ! 			     "component a PURE procedure (12.6)",
>   			     &code->expr2->where);
I did not see the above message covered in the test case given here.  Is it 
covered elsewhere?

Also, the grammar should be "component of a Pure" or "component in a Pure" 
depending on your intent.

Otherwise OK to commit to trunk. I also tested.

Jerry



More information about the Fortran mailing list