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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147663
138bc75d-0d04-0410-961f-
82ee72b054a4
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>
+
* intrinsic.c (add_sym): Fix my last commit (r147655),
which broke bootstrap.
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;
if (!comp->attr.subroutine)
gfc_add_subroutine (&comp->attr, comp->name, &c->expr1->where);
+ if (resolve_ref (c->expr1) == FAILURE)
+ return FAILURE;
+
if (resolve_actual_arglist (c->ext.actual, comp->attr.proc,
comp->formal == NULL) == FAILURE)
return FAILURE;
if (!comp->attr.function)
gfc_add_function (&comp->attr, comp->name, &e->where);
+ if (resolve_ref (e) == FAILURE)
+ return FAILURE;
+
if (resolve_actual_arglist (e->value.function.actual, comp->attr.proc,
comp->formal == NULL) == FAILURE)
return FAILURE;
&& sym != c->ts.derived)
add_dt_to_dt_list (c->ts.derived);
- if (c->attr.pointer || c->attr.allocatable || c->as == NULL)
+ if (c->attr.pointer || c->attr.proc_pointer || c->attr.allocatable
+ || c->as == NULL)
continue;
for (i = 0; i < c->as->rank; i++)
+2009-05-18 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/40164
+ * gfortran.dg/proc_ptr_comp_8.f90: New.
+
2009-05-18 Richard Guenther <rguenther@suse.de>
PR fortran/40168
--- /dev/null
+! { dg-do run }
+!
+! PR 40164: Fortran 2003: "Arrays of procedure pointers" (using PPCs)
+!
+! Original test case by Barron Bichon <barron.bichon@swri.org>
+! Adapted by Janus Weil <janus@gcc.gnu.org>
+
+PROGRAM test_prog
+
+ ABSTRACT INTERFACE
+ FUNCTION fn_template(n,x) RESULT(y)
+ INTEGER, INTENT(in) :: n
+ REAL, INTENT(in) :: x(n)
+ REAL :: y(n)
+ END FUNCTION fn_template
+ END INTERFACE
+
+ TYPE PPA
+ PROCEDURE(fn_template), POINTER, NOPASS :: f
+ END TYPE PPA
+
+ TYPE ProcPointerArray
+ PROCEDURE(add), POINTER, NOPASS :: f
+ END TYPE ProcPointerArray
+
+ TYPE (ProcPointerArray) :: f_array(3)
+ PROCEDURE(add), POINTER :: f
+ real :: r
+
+ f_array(1)%f => add
+ f => f_array(1)%f
+ f_array(2)%f => sub
+ f_array(3)%f => f_array(1)%f
+
+ r = f(1.,2.)
+ if (abs(r-3.)>1E-3) call abort()
+ r = f_array(1)%f(4.,2.)
+ if (abs(r-6.)>1E-3) call abort()
+ r = f_array(2)%f(5.,3.)
+ if (abs(r-2.)>1E-3) call abort()
+ if (abs(f_array(1)%f(1.,3.)-f_array(3)%f(2.,2.))>1E-3) call abort()
+
+CONTAINS
+
+ FUNCTION add(a,b) RESULT(sum)
+ REAL, INTENT(in) :: a, b
+ REAL :: sum
+ sum = a + b
+ END FUNCTION add
+
+ FUNCTION sub(a,b) RESULT(diff)
+ REAL, INTENT(in) :: a, b
+ REAL :: diff
+ diff = a - b
+ END FUNCTION sub
+
+END PROGRAM test_prog
+