: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);