From 6e98bce41ede3e64ea559278e6a6f386cb45b141 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Fri, 1 Apr 2011 19:31:23 +0000 Subject: [PATCH] re PR fortran/48352 (segfault in fortran/frontend-passes.c) 2011-04-01 Thomas Koenig 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 PR fortran/48352 * gfortran.dg/function_optimize_3.f90: New test. From-SVN: r171849 --- gcc/fortran/ChangeLog | 8 +++++++- gcc/fortran/frontend-passes.c | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/function_optimize_3.f90 | 9 +++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/function_optimize_3.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b651ae235fd..c2e1fa023e4 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,4 +1,10 @@ -2011-03-30 Michael Matz matz@suse.de> +2011-04-01 Thomas Koenig + + 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 PR fortran/47516 * trans-expr.c (realloc_lhs_loop_for_fcn_call): Take loop as parameter, diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 6e59c37cdbc..755bae0645d 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 19ab50df6db..be2d1961bf5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-04-01 Thomas Koenig + + PR fortran/48352 + * gfortran.dg/function_optimize_3.f90: New test. + 2011-04-01 Bernd Schmidt * 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 index 00000000000..71381f4c953 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/function_optimize_3.f90 @@ -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 -- 2.30.2