From f0051264182ba3d09445f169bfb10b660127f4da Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Thu, 25 Jul 2013 23:41:22 +0200 Subject: [PATCH] re PR fortran/57966 ([OOP] Using a TBP to specify the shape of a dummy argument) 2013-07-25 Janus Weil PR fortran/57966 * resolve.c (resolve_typebound_function): Make sure the declared type, including its type-bound procedures, is resolved before resolving the actual type-bound call. 2013-07-25 Janus Weil PR fortran/57966 * gfortran.dg/typebound_call_25.f90: New. From-SVN: r201254 --- gcc/fortran/ChangeLog | 7 ++++ gcc/fortran/resolve.c | 5 +++ gcc/testsuite/ChangeLog | 5 +++ .../gfortran.dg/typebound_call_25.f90 | 38 +++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/typebound_call_25.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d4cc08358e1..0723c6d80a0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2013-07-25 Janus Weil + + PR fortran/57966 + * resolve.c (resolve_typebound_function): Make sure the declared type, + including its type-bound procedures, is resolved before resolving the + actual type-bound call. + 2013-07-25 Janus Weil PR fortran/57639 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 08e197b7c72..c3487881631 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -5686,6 +5686,8 @@ resolve_compcall (gfc_expr* e, const char **name) } +static bool resolve_fl_derived (gfc_symbol *sym); + /* Resolve a typebound function, or 'method'. First separate all the non-CLASS references by calling resolve_compcall directly. */ @@ -5772,6 +5774,9 @@ resolve_typebound_function (gfc_expr* e) /* Get the CLASS declared type. */ declared = get_declared_from_expr (&class_ref, &new_ref, e, true); + + if (!resolve_fl_derived (declared)) + return false; /* Weed out cases of the ultimate component being a derived type. */ if ((class_ref && class_ref->u.c.component->ts.type == BT_DERIVED) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b47813e5dfb..202cdaa8920 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-07-25 Janus Weil + + PR fortran/57966 + * gfortran.dg/typebound_call_25.f90: New. + 2013-07-25 Paolo Carlini PR c++/57981 diff --git a/gcc/testsuite/gfortran.dg/typebound_call_25.f90 b/gcc/testsuite/gfortran.dg/typebound_call_25.f90 new file mode 100644 index 00000000000..df81c79e627 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_call_25.f90 @@ -0,0 +1,38 @@ +! { dg-do compile } +! +! PR 57966: [OOP] Using a TBP to specify the shape of a dummy argument +! +! Contributed by Stefan Mauerberger + +MODULE my_mod + IMPLICIT NONE + + TYPE config_cls + CONTAINS + PROCEDURE, NOPASS :: my_size + PROCEDURE, NOPASS :: my_sub + GENERIC :: sz => my_size + GENERIC :: sub => my_sub + END TYPE + + TYPE(config_cls) :: config + +CONTAINS + + PURE INTEGER FUNCTION my_size() + my_size = 10 + END FUNCTION + + SUBROUTINE my_sub + END SUBROUTINE + + SUBROUTINE test (field1, field2, field3, field4) + REAL :: field1 (config%my_size()) + REAL :: field2 (config%sz()) + REAL :: field3 (config%my_sub()) ! { dg-error "should be a FUNCTION" } + REAL :: field4 (config%sub()) ! { dg-error "should be a FUNCTION" } + END SUBROUTINE + +END MODULE + +! { dg-final { cleanup-modules "my_mod" } } -- 2.30.2