re PR fortran/48352 (segfault in fortran/frontend-passes.c)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Fri, 1 Apr 2011 19:31:23 +0000 (19:31 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Fri, 1 Apr 2011 19:31:23 +0000 (19:31 +0000)
2011-04-01  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/48352
* frontend-passes (cfe_register_funcs):  Don't
register functions if they appear as iterators in DO loops.

2011-04-01  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/48352
* gfortran.dg/function_optimize_3.f90:  New test.

From-SVN: r171849

gcc/fortran/ChangeLog
gcc/fortran/frontend-passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/function_optimize_3.f90 [new file with mode: 0644]

index b651ae235fd5dfe08b7761c23ce603d3ce3258e9..c2e1fa023e4dcde6a498812ab595bfb69486e628 100644 (file)
@@ -1,4 +1,10 @@
-2011-03-30  Michael Matz  matz@suse.de>
+2011-04-01  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/48352
+       * frontend-passes (cfe_register_funcs):  Don't
+       register functions if they appear as iterators in DO loops.
+
+2011-03-30  Michael Matz  <matz@suse.de>
 
        PR fortran/47516
        * trans-expr.c (realloc_lhs_loop_for_fcn_call): Take loop as parameter,
index 6e59c37cdbcbcd25812d8453e36e677342fb1f73..755bae0645de0ff5c4f8e6fd127a07c83709fc8d 100644 (file)
@@ -137,6 +137,13 @@ static int
 cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED,
          void *data ATTRIBUTE_UNUSED)
 {
+
+  /* FIXME - there is a bug in the insertion code for DO loops.  Bail
+     out here.  */
+
+  if ((*current_code)->op == EXEC_DO)
+    return 0;
+
   if ((*e)->expr_type != EXPR_FUNCTION)
     return 0;
 
index 19ab50df6db0107f9c0857142aafd5494ec6fce3..be2d1961bf51b118cc28aec12b080f1a95d1abf6 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-01  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/48352
+       * gfortran.dg/function_optimize_3.f90:  New test.
+
 2011-04-01  Bernd Schmidt  <bernds@codesourcery.com>
 
        * gcc.c-torture/compile/20110401-1.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/function_optimize_3.f90 b/gcc/testsuite/gfortran.dg/function_optimize_3.f90
new file mode 100644 (file)
index 0000000..71381f4
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! { dg-options "-O" }
+! PR 48352 - variable elimination in a DO loop caused segfaults.
+! Test case contributed by Joost VandeVondele
+program main
+  INTEGER, DIMENSION(:), POINTER :: a
+  DO I=1,MIN(SIZE(a),SIZE(a))
+  ENDDO
+END program main