re PR fortran/78300 ([OOP] Failure to compile a F03 code with an optional dummy proce...
authorJanus Weil <janus@gcc.gnu.org>
Mon, 14 Nov 2016 16:55:01 +0000 (17:55 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Mon, 14 Nov 2016 16:55:01 +0000 (17:55 +0100)
2016-11-14  Janus Weil  <janus@gcc.gnu.org>

PR fortran/78300
* resolve.c (resolve_procedure_interface): Properly handle CLASS-valued
function results.

2016-11-14  Janus Weil  <janus@gcc.gnu.org>

PR fortran/78300
* gfortran.dg/class_result_3.f90: New test.

From-SVN: r242392

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

index b5324f255fab5cf935d5a825b79460336e2c84fb..6c0ede1186f4d9a0e20b081252b236bad593e165 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-14  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/78300
+       * resolve.c (resolve_procedure_interface): Properly handle CLASS-valued
+       function results.
+
 2016-11-13  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/60952
index c85525aabb9e557cc03367c3566257514819a797..825bb12a517bdb2639d3660e4d7afe1b55882bb7 100644 (file)
@@ -214,27 +214,33 @@ resolve_procedure_interface (gfc_symbol *sym)
       if (ifc->result)
        {
          sym->ts = ifc->result->ts;
+         sym->attr.allocatable = ifc->result->attr.allocatable;
+         sym->attr.pointer = ifc->result->attr.pointer;
+         sym->attr.dimension = ifc->result->attr.dimension;
+         sym->attr.class_ok = ifc->result->attr.class_ok;
+         sym->as = gfc_copy_array_spec (ifc->result->as);
          sym->result = sym;
        }
       else
-       sym->ts = ifc->ts;
+       {
+         sym->ts = ifc->ts;
+         sym->attr.allocatable = ifc->attr.allocatable;
+         sym->attr.pointer = ifc->attr.pointer;
+         sym->attr.dimension = ifc->attr.dimension;
+         sym->attr.class_ok = ifc->attr.class_ok;
+         sym->as = gfc_copy_array_spec (ifc->as);
+       }
       sym->ts.interface = ifc;
       sym->attr.function = ifc->attr.function;
       sym->attr.subroutine = ifc->attr.subroutine;
 
-      sym->attr.allocatable = ifc->attr.allocatable;
-      sym->attr.pointer = ifc->attr.pointer;
       sym->attr.pure = ifc->attr.pure;
       sym->attr.elemental = ifc->attr.elemental;
-      sym->attr.dimension = ifc->attr.dimension;
       sym->attr.contiguous = ifc->attr.contiguous;
       sym->attr.recursive = ifc->attr.recursive;
       sym->attr.always_explicit = ifc->attr.always_explicit;
       sym->attr.ext_attr |= ifc->attr.ext_attr;
       sym->attr.is_bind_c = ifc->attr.is_bind_c;
-      sym->attr.class_ok = ifc->attr.class_ok;
-      /* Copy array spec.  */
-      sym->as = gfc_copy_array_spec (ifc->as);
       /* Copy char length.  */
       if (ifc->ts.type == BT_CHARACTER && ifc->ts.u.cl)
        {
index e9485591659a2414c8ab2ec236a52544c91b1790..54eb9b3db0810dac37a04ff67ff6a52d26061a93 100644 (file)
@@ -1,6 +1,11 @@
+2016-11-14  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/78300
+       * gfortran.dg/class_result_3.f90: New test.
+
 2016-11-14  Prasad Ghangal  <prasad.ghangal@gmail.com>
        Richard Biener  <rguenther@suse.de>
-    
+
        * gcc.dg/gimplefe-1.c: New testcase.
        * gcc.dg/gimplefe-2.c: Likewise.
        * gcc.dg/gimplefe-3.c: Likewise.
diff --git a/gcc/testsuite/gfortran.dg/class_result_3.f90 b/gcc/testsuite/gfortran.dg/class_result_3.f90
new file mode 100644 (file)
index 0000000..39d6c1e
--- /dev/null
@@ -0,0 +1,22 @@
+! { dg-do compile }
+!
+! PR 78300: [OOP] Failure to compile a F03 code with an optional dummy procedure argument
+!
+! Contributed by DIL <liakhdi@ornl.gov>
+
+  implicit none
+
+  type gfc_cont_elem_t
+  end type
+
+  contains
+
+    function gfc_copy_i() result(clone)
+      class(gfc_cont_elem_t), pointer:: clone
+    end
+
+    subroutine ContElemConstruct(copy_constr_func)
+      procedure(gfc_copy_i) :: copy_constr_func
+    end
+
+end