re PR fortran/37411 (ICE (segfault) in trans-array.c)
authorDaniel Kraft <d@domob.eu>
Tue, 9 Sep 2008 09:46:51 +0000 (11:46 +0200)
committerDaniel Kraft <domob@gcc.gnu.org>
Tue, 9 Sep 2008 09:46:51 +0000 (11:46 +0200)
2008-09-09  Daniel Kraft  <d@domob.eu>

PR fortran/37411
* trans-array.c (gfc_conv_array_parameter): Added assertion that the
symbol has an array spec.

2008-09-09  Daniel Kraft  <d@domob.eu>

PR fortran/37411
* gfortran.dg/array_function_4.f90: New test.

From-SVN: r140141

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/array_function_4.f90 [new file with mode: 0644]

index 39b68d8..4cabf02 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-09  Daniel Kraft  <d@domob.eu>
+
+       PR fortran/37411
+       * trans-array.c (gfc_conv_array_parameter): Added assertion that the
+       symbol has an array spec.
+
 2008-09-08  Daniel Kraft  <d@domob.eu>
 
        PR fortran/37199
index e0ebbf0..1ab58e1 100644 (file)
@@ -5155,6 +5155,9 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77,
                      && expr->ref->u.ar.type == AR_FULL);
   sym = full_array_var ? expr->symtree->n.sym : NULL;
 
+  /* The symbol should have an array specification.  */
+  gcc_assert (!sym || sym->as);
+
   if (expr->expr_type == EXPR_ARRAY && expr->ts.type == BT_CHARACTER)
     {
       get_array_ctor_strlen (&se->pre, expr->value.constructor, &tmp);
index e5ee823..02f9112 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-09  Daniel Kraft  <d@domob.eu>
+
+       PR fortran/37411
+       * gfortran.dg/array_function_4.f90: New test.
+
 2008-09-08  Daniel Jacobowitz  <dan@codesourcery.com>
            Mark Mitchell  <mark@codesourcery.com>
 
diff --git a/gcc/testsuite/gfortran.dg/array_function_4.f90 b/gcc/testsuite/gfortran.dg/array_function_4.f90
new file mode 100644 (file)
index 0000000..c7e7d6e
--- /dev/null
@@ -0,0 +1,29 @@
+! { dg-do compile }
+
+! PR fortran/37411
+! This used to cause an ICE because of a missing array spec after interface
+! mapping.
+
+! Contributed by Kristjan Jonasson <jonasson@hi.is>
+
+MODULE B1
+CONTAINS
+  subroutine sub()
+    integer :: x(1)
+    character(3) :: st
+    st = fun(x)
+  end subroutine sub
+
+  function fun(x) result(st)
+    integer, intent(in) :: x(1)
+    character(lenf(x)) :: st
+    st = 'abc'
+  end function fun
+
+  pure integer function lenf(x)
+    integer, intent(in) :: x(1)
+    lenf = x(1)
+  end function lenf
+END MODULE B1
+
+! { dg-final { cleanup-modules "B1" } }