[PATCH] fortran/45495 -- optional dummy args cannot not be in restricted expressions
Tobias Burnus
burnus@net-b.de
Fri Sep 3 06:36:00 GMT 2010
Steve Kargl wrote:
> C710 (R729) The scalar-int-expr shall be a restricted expression.
> (2) An object designator with a base object that is a dummy
> argument that has neither the OPTIONAL nor the INTENT(OUT)
> attribute,
>
> The attach patch enforces the above restriction. It has been
> built and regression tested on x86_64-*-freebsd. OK for trunk?
+ if (not_restricted == 0
+ && ap->expr->expr_type == EXPR_VARIABLE
+ && ap->expr->symtree->n.sym->attr.optional
+ && ap->expr->symtree->n.sym->attr.dummy)
The "sym.dummy" part is not needed (but can stay). However, can you add
you add a check whether the dummy is INTENT(OUT)? The following is
invalid and not detected:
subroutine f(a, str)
integer, intent(out) :: a
character(*) :: str
character(len=len(str(1:a))+1) :: b
end subroutine
With that change and test case, the patch is OK.
Thanks for the patch and digging for the constraint!
Tobias
> 2010-09-02 Steven G. Kargl<kargl@gcc.gnu.org>
>
> PR fortran/45495
> * gfortran.dg/dummy_optional_arg.f90: New test.
>
> 2010-09-02 Steven G. Kargl<kargl@gcc.gnu.org>
>
> PR fortran/45495
> * fortran/expr.c (check_inquiry): Optional dummy argument are not
> permitted in a restricted expression.
>
More information about the Gcc-patches
mailing list