This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR18578, PR18579, PR20857 and PR20885 - Constraints on INTENT(OUT and INOUT)
Paul:
Are you OK with this minimalist version? All the probing of undefined
variables has gone. All that remains is the test for the actual being
definable.
This patch implements the obvious constraint on the use of INTENT(OUT
and INOUT). ie: that the actual argument should be a variable
("definable" in the standard). The patch is straightforward.
Regtested on Athlon/FC3. OK for 4.2 and 4.1?
Paul
2006-01-29 Paul Thomas <pault@gcc.gnu.org>
PR fortran/18578
PR fortran/18579
PR fortran/20857
PR fortran/20885
* interface.c (compare_actual_formal): Error for INTENT(OUT or INOUT)
if actual argument is not a variable.
2006-01-29 Paul Thomas <pault@gcc.gnu.org>
PR fortran/18578
PR fortran/18579
PR fortran/20857
PR fortran/20885
* gfortran.dg/intent_out_1.f90: New test.
Index: gcc/fortran/interface.c
===================================================================
*** gcc/fortran/interface.c (revision 110364)
--- gcc/fortran/interface.c (working copy)
*************** compare_actual_formal (gfc_actual_arglis
*** 1273,1278 ****
--- 1273,1288 ----
return 0;
}
+ /* Check intent = OUT/INOUT for definable actual argument. */
+ if (a->expr->expr_type != EXPR_VARIABLE
+ && (f->sym->attr.intent == INTENT_OUT
+ || f->sym->attr.intent == INTENT_INOUT))
+ {
+ gfc_error ("Actual argument at %L must be definable to "
+ "match dummy INTENT = OUT/INOUT", &a->expr->where);
+ return 0;
+ }
+
match:
if (a == actual)
na = i;
! { dg-do compile }
! Tests the fix for PRs 18578, 18579 and their repeats 20857 and 20885.
! Contributed by Paul Thomas <pault@gcc@gnu.org>
real, parameter :: a =42.0
real :: b
call foo(b + 2.0) ! { dg-error "must be definable" }
call foo(a) ! { dg-error "must be definable" }
call bar(b + 2.0) ! { dg-error "must be definable" }
call bar(a) ! { dg-error "must be definable" }
contains
subroutine foo(a)
real, intent(out) :: a
a = 0.0
end subroutine foo
subroutine bar(a)
real, intent(INout) :: a
a = 0.0
end subroutine bar
end
- References:
- [Patch, fortran] PR18578, PR18579, PR20857 and PR20885 - Constraints on INTENT(OUT and INOUT)
- Re: [Patch, fortran] PR18578, PR18579, PR20857 and PR20885 - Constraints on INTENT(OUT and INOUT)
- Re: [Patch, fortran] PR18578, PR18579, PR20857 and PR20885 - Constraints on INTENT(OUT and INOUT)
- Re: [Patch, fortran] PR18578, PR18579, PR20857 and PR20885 - Constraints on INTENT(OUT and INOUT)