Commit 8d231ff2 by Tobias Burnus Committed by Tobias Burnus

re PR fortran/49255 (-fcheck=pointer diagnoses too much: Passing NULL pointer to OPTIONAL argument)

2011-06-05  Tobias Burnus  <burnus@net-b.de>

        PR fortran/49255
        * trans-expr.c (gfc_conv_procedure_call): Fix -fcheck=pointer
        for F2008.

2011-06-05  Tobias Burnus  <burnus@net-b.de>

        PR fortran/49255
        * gfortran.dg/pointer_check_9.f90: New.
        * gfortran.dg/pointer_check_10.f90: New.

From-SVN: r174663
parent e8f79869
2011-06-05 Tobias Burnus <burnus@net-b.de>
PR fortran/49255
* trans-expr.c (gfc_conv_procedure_call): Fix -fcheck=pointer
for F2008.
2011-06-05 Andreas Schmidt <andreas.schmidt.42@gmx.net>
Thomas Koenig <tkoenig@gcc.gnu.org>
......
......@@ -3269,6 +3269,12 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
else
goto end_pointer_check;
/* In Fortran 2008 it's allowed to pass a NULL pointer/nonallocated
allocatable to an optional dummy, cf. 12.5.2.12. */
if (fsym != NULL && fsym->attr.optional && !attr.proc_pointer
&& (gfc_option.allow_std & GFC_STD_F2008) != 0)
goto end_pointer_check;
if (attr.optional)
{
/* If the actual argument is an optional pointer/allocatable and
......
2011-06-05 Tobias Burnus <burnus@net-b.de>
PR fortran/49255
* trans-expr.c (gfc_conv_procedure_call): Fix -fcheck=pointer
for F2008.
2011-06-05 Nicola Pero <nicola.pero@meta-innovation.com>
PR testsuite/49287
......
! { dg-do run }
! { dg-options "-fcheck=all -std=f2003 -fall-intrinsics" }
! { dg-shouldfail "Pointer actual argument 'ptr' is not associated" }
!
! PR fortran/49255
!
! Valid F2008, invalid F95/F2003.
!
integer,pointer :: ptr => null()
call foo (ptr)
contains
subroutine foo (x)
integer, optional :: x
if (present (x)) call abort ()
end subroutine foo
end
! { dg-do run }
! { dg-options "-fcheck=all -std=f2008 -fall-intrinsics" }
!
! PR fortran/49255
!
! Valid F2008, invalid F95/F2003.
!
integer,pointer :: ptr => null()
call foo (ptr)
contains
subroutine foo (x)
integer, optional :: x
if (present (x)) call abort ()
end subroutine foo
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment