re PR fortran/66257 (ELEMENTAL procedure pointer component XX is not allowed as an...
authorMikael Morin <mikael@gcc.gnu.org>
Sun, 24 May 2015 14:55:50 +0000 (14:55 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Sun, 24 May 2015 14:55:50 +0000 (14:55 +0000)
PR fortran/66257
gcc/fortran/
* resolve.c (resolve_actual_arglist): Don't throw an error
if the argument with procedure pointer component is not a variable.
gcc/testsuite/
* typebound_call_27.f90: New file.

From-SVN: r223631

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

index 420a99d77884be595a04daa5ca68295799b80154..bc623c4dbdea8e27fb0c344dcd7fcf4bbc89f9d8 100644 (file)
@@ -1,3 +1,9 @@
+2015-05-24  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/66257
+       * resolve.c (resolve_actual_arglist): Don't throw an error
+       if the argument with procedure pointer component is not a variable.
+
 2015-05-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR fortran/44054
index 492c016ad9c7eda5990d78d38db950b1ac55c0bd..e615cc6dfb24634b1c2136b6edf52d65bd28e33d 100644 (file)
@@ -1981,7 +1981,8 @@ resolve_actual_arglist (gfc_actual_arglist *arg, procedure_type ptype,
        }
 
       comp = gfc_get_proc_ptr_comp(e);
-      if (comp && comp->attr.elemental)
+      if (e->expr_type == EXPR_VARIABLE
+         && comp && comp->attr.elemental)
        {
            gfc_error ("ELEMENTAL procedure pointer component %qs is not "
                       "allowed as an actual argument at %L", comp->name,
index e302f01257a2040b31519910e5a452097492e6af..41a478d4dea842e6ede68a31a00e7c5d29c3eef0 100644 (file)
@@ -1,3 +1,8 @@
+2015-05-24  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/66257
+       * typebound_call_27.f90: New file.
+
 2015-05-23  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/65936
diff --git a/gcc/testsuite/gfortran.dg/typebound_call_27.f90 b/gcc/testsuite/gfortran.dg/typebound_call_27.f90
new file mode 100644 (file)
index 0000000..f183ebb
--- /dev/null
@@ -0,0 +1,41 @@
+! { dg-do compile }
+!
+! PR fortran/66257
+! Check that typebound function calls are accepted as actual argument.
+!
+MODULE test_class
+  IMPLICIT NONE
+  PRIVATE
+  PUBLIC:: test
+
+  INTEGER, PARAMETER :: dp  = SELECTED_REAL_KIND(15)
+
+  TYPE test
+      PRIVATE
+      CONTAINS
+          PRIVATE
+              PROCEDURE, PUBLIC:: E
+              PROCEDURE, PUBLIC:: Om
+  END TYPE test
+
+CONTAINS
+
+  ELEMENTAL FUNCTION E (self, a)
+    IMPLICIT NONE
+    CLASS(test), INTENT(IN):: self
+    REAL(kind=dp), INTENT(IN):: a
+    REAL(kind=dp):: E
+
+    E = a
+  END FUNCTION E
+
+  ELEMENTAL FUNCTION Om (self, z)
+    IMPLICIT NONE
+    CLASS(test), INTENT(IN):: self
+    REAL(kind=dp), INTENT(IN):: z
+    REAL(kind=dp):: Om
+
+    Om = self%E(self%E(z))
+    Om = log10(self%E(z))
+  END FUNCTION Om
+END MODULE test_class