re PR fortran/46100 ([Fortran 2008] Non-variable pointer expression as actual argument to INTENT(OUT) non-pointer dummy)

2010-10-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/46100
        * expr.c (gfc_check_vardef_context): Treat pointer functions
        as variables.

2010-10-21  Tobias Burnus  <burnus@net-b.de>

        PR fortran/46100
        * gfortran.dg/ptr-func-1.f90: New.
        * gfortran.dg/ptr-func-2.f90: New.

From-SVN: r165749
This commit is contained in:
Tobias Burnus 2010-10-21 08:15:30 +02:00 committed by Tobias Burnus
parent 0fd4b31d68
commit 9b565d6546
5 changed files with 72 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2010-10-21 Tobias Burnus <burnus@net-b.de>
PR fortran/46100
* expr.c (gfc_check_vardef_context): Treat pointer functions
as variables.
2010-10-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/46079

View File

@ -4316,7 +4316,18 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, const char* context)
symbol_attribute attr;
gfc_ref* ref;
if (e->expr_type != EXPR_VARIABLE)
if (!pointer && e->expr_type == EXPR_FUNCTION
&& e->symtree->n.sym->result->attr.pointer)
{
if (!(gfc_option.allow_std & GFC_STD_F2008))
{
if (context)
gfc_error ("Fortran 2008: Pointer functions in variable definition"
" context (%s) at %L", context, &e->where);
return FAILURE;
}
}
else if (e->expr_type != EXPR_VARIABLE)
{
if (context)
gfc_error ("Non-variable expression in variable definition context (%s)"

View File

@ -1,3 +1,9 @@
2010-10-21 Tobias Burnus <burnus@net-b.de>
PR fortran/46100
* gfortran.dg/ptr-func-1.f90: New.
* gfortran.dg/ptr-func-2.f90: New.
2010-10-20 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/45919

View File

@ -0,0 +1,24 @@
! { dg-do compile }
! { dg-options "-std=f2008 -fall-intrinsics" }
!
! PR fortran/46100
!
! Pointer function as definable actual argument
! - a Fortran 2008 feature
!
integer, target :: tgt
call one (two ())
if (tgt /= 774) call abort ()
contains
subroutine one (x)
integer, intent(inout) :: x
if (x /= 34) call abort ()
x = 774
end subroutine one
function two ()
integer, pointer :: two
two => tgt
two = 34
end function two
end

View File

@ -0,0 +1,24 @@
! { dg-do compile }
! { dg-options "-std=f2003 -fall-intrinsics" }
!
! PR fortran/46100
!
! Pointer function as definable actual argument
! - a Fortran 2008 feature
!
integer, target :: tgt
call one (two ()) ! { dg-error "Fortran 2008: Pointer functions" }
if (tgt /= 774) call abort ()
contains
subroutine one (x)
integer, intent(inout) :: x
if (x /= 34) call abort ()
x = 774
end subroutine one
function two ()
integer, pointer :: two
two => tgt
two = 34
end function two
end