2010-06-11 Paul Thomas <pault@gcc.gnu.org>
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Jun 2010 16:45:48 +0000 (16:45 +0000)
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Jun 2010 16:45:48 +0000 (16:45 +0000)
PR fortran/42051
PR fortran/43896
* trans-expr.c (gfc_conv_derived_to_class): Handle array-valued
functions with CLASS formal arguments.

2010-06-11  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/42051
PR fortran/43896
* gfortran.dg/class_23.f03: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160622 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_23.f03 [new file with mode: 0644]

index 6cf60ee..6f17693 100644 (file)
@@ -1,3 +1,10 @@
+2010-06-11  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/42051
+       PR fortran/43896
+       * trans-expr.c (gfc_conv_derived_to_class): Handle array-valued
+       functions with CLASS formal arguments.
+
 2010-06-10  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/44207
index 6c5c328..416e67d 100644 (file)
@@ -2492,12 +2492,14 @@ gfc_conv_derived_to_class (gfc_se *parmse, gfc_expr *e,
   ss = gfc_walk_expr (e);
   if (ss == gfc_ss_terminator)
     {
+      parmse->ss = NULL;
       gfc_conv_expr_reference (parmse, e);
       tmp = fold_convert (TREE_TYPE (ctree), parmse->expr);
       gfc_add_modify (&parmse->pre, ctree, tmp);
     }
   else
     {
+      parmse->ss = ss;
       gfc_conv_expr (parmse, e);
       gfc_add_modify (&parmse->pre, ctree, parmse->expr);
     }
index ce3db3e..aeda5b9 100644 (file)
@@ -1,3 +1,9 @@
+2010-06-11  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/42051
+       PR fortran/43896
+       * gfortran.dg/class_23.f03: New test.
+
 2010-06-11  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/ipa/pure-const-2.c: New testcase.
diff --git a/gcc/testsuite/gfortran.dg/class_23.f03 b/gcc/testsuite/gfortran.dg/class_23.f03
new file mode 100644 (file)
index 0000000..e1e3517
--- /dev/null
@@ -0,0 +1,24 @@
+! { dg-do compile }
+!
+! PR 42051: [OOP] ICE on array-valued function with CLASS formal argument
+!
+! Original test case by Damian Rouson <damian@rouson.net>
+! Modified by Janus Weil <janus@gcc.gnu.org>
+
+  type grid
+  end type 
+
+contains
+
+  function return_x(this) result(this_x)
+    class(grid) :: this
+    real  ,dimension(1) :: this_x
+  end function
+
+  subroutine output()
+    type(grid) :: mesh
+    real ,dimension(1) :: x
+    x = return_x(mesh)
+  end subroutine
+
+end