re PR fortran/57966 ([OOP] Using a TBP to specify the shape of a dummy argument)
authorJanus Weil <janus@gcc.gnu.org>
Thu, 25 Jul 2013 21:41:22 +0000 (23:41 +0200)
committerJanus Weil <janus@gcc.gnu.org>
Thu, 25 Jul 2013 21:41:22 +0000 (23:41 +0200)
2013-07-25  Janus Weil  <janus@gcc.gnu.org>

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  <janus@gcc.gnu.org>

PR fortran/57966
* gfortran.dg/typebound_call_25.f90: New.

From-SVN: r201254

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/typebound_call_25.f90 [new file with mode: 0644]

index d4cc08358e19129a8817d21c1c8a4514dde605d3..0723c6d80a012b6d95d0433a837f8cd5478c9c6d 100644 (file)
@@ -1,3 +1,10 @@
+2013-07-25  Janus Weil  <janus@gcc.gnu.org>
+
+       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  <janus@gcc.gnu.org>
 
        PR fortran/57639
index 08e197b7c729a7e39bdad9ce1f1e13a0ac022be4..c34878816319e3b811920c4bedfc4eac5754e620 100644 (file)
@@ -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)
index b47813e5dfb51c541579cb97e7c95b7cb84bc3f0..202cdaa89201fc126a39cf44f87baf4d4091aee5 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-25  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/57966
+       * gfortran.dg/typebound_call_25.f90: New.
+
 2013-07-25  Paolo Carlini  <paolo.carlini@oracle.com>
 
        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 (file)
index 0000000..df81c79
--- /dev/null
@@ -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 <stefan.mauerberger@gmail.com>
+
+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" } }