PROGRAM test_prog TYPE ProcPointerArray PROCEDURE(add), POINTER, NOPASS :: f END TYPE ProcPointerArray TYPE (ProcPointerArray) :: f_array(1) PROCEDURE(add), POINTER :: f f_array(1)%f => add f => f_array(1)%f PRINT*, f(2.,4.) CONTAINS FUNCTION add(a,b) RESULT(sum) REAL, INTENT(in) :: a, b REAL :: sum sum = a + b END FUNCTION add END PROGRAM test_prog This produces the error f => f_array(1)%f 1 Error: VARIABLE attribute of 'f_array' conflicts with PROCEDURE attribute at (1) Reported by Barron Bichon.
Here is a small patch which fixes the test case: Index: gcc/fortran/primary.c =================================================================== --- gcc/fortran/primary.c (revision 147527) +++ gcc/fortran/primary.c (working copy) @@ -2558,7 +2558,7 @@ if (gfc_matching_procptr_assignment) { gfc_gobble_whitespace (); - if (gfc_peek_ascii_char () == '(') + if (!sym->attr.dimension && gfc_peek_ascii_char () == '(') /* Parse functions returning a procptr. */ goto function0;
Adding in the test case a line like print *, f_array(1)%f(3.,5.) produces a segfault in gfc_conv_scalarized_array_ref (trans-array.c, 2414).
Subject: Bug 40164 Author: janus Date: Mon May 18 14:44:55 2009 New Revision: 147663 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147663 Log: 2009-05-18 Janus Weil <janus@gcc.gnu.org> PR fortran/40164 * primary.c (gfc_match_rvalue): Handle procedure pointer components in arrays. * resolve.c (resolve_ppc_call,resolve_expr_ppc): Resolve component and array references. (resolve_fl_derived): Procedure pointer components are not required to have constant array bounds in their return value. 2009-05-18 Janus Weil <janus@gcc.gnu.org> PR fortran/40164 * gfortran.dg/proc_ptr_comp_8.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_8.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/primary.c trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog
Fixed with r147663. Closing.