From 9658d116f335629a3fae673474412cf8044d3d3e Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Wed, 6 Jun 2018 21:41:29 +0000 Subject: [PATCH] re PR fortran/85641 (ICE with string concatenate) 2018-06-06 Thomas Koenig PR fortran/85641 * frontend-passes.c (is_fe_temp): Add prototype. (realloc_string_callback): Early return for frontend-generated temporary. 2018-06-06 Thomas Koenig PR fortran/85641 * gfortran.dg/realloc_on_assign_30.f90: New test. From-SVN: r261248 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/frontend-passes.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/realloc_on_assign_30.f90 | 13 +++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/realloc_on_assign_30.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 23a40650583..e69ff8e4f42 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-06-06 Thomas Koenig + + PR fortran/85641 + * frontend-passes.c (is_fe_temp): Add prototype. + (realloc_string_callback): Early return for frontend-generated + temporary. + 2018-06-05 Cesar Philippidis PR fortran/85701 diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 40e88b1a7d4..c13366cf138 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -57,6 +57,8 @@ static bool has_dimen_vector_ref (gfc_expr *); static int matmul_temp_args (gfc_code **, int *,void *data); static int index_interchange (gfc_code **, int*, void *); +static bool is_fe_temp (gfc_expr *e); + #ifdef CHECKING_P static void check_locus (gfc_namespace *); #endif @@ -254,6 +256,9 @@ realloc_string_callback (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, || !expr1->ts.deferred) return 0; + if (is_fe_temp (expr1)) + return 0; + expr2 = gfc_discard_nops (co->expr2); if (expr2->expr_type == EXPR_VARIABLE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 32c661d74c3..41b78f28a28 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-06 Thomas Koenig + + PR fortran/85641 + * gfortran.dg/realloc_on_assign_30.f90: New test. + 2018-06-06 Carl Love * gcc.target/powerpc/builtins-3.c: Move tests requiring -mvsx diff --git a/gcc/testsuite/gfortran.dg/realloc_on_assign_30.f90 b/gcc/testsuite/gfortran.dg/realloc_on_assign_30.f90 new file mode 100644 index 00000000000..4e7eb4ba220 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/realloc_on_assign_30.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! PR 85641 - this used to ICE due do infinite recursion. +! Test case by Antony Lewis. +program tester +character(LEN=:), allocatable :: fields +integer j +character(LEN=4), parameter :: CMB_CL_Fields = 'TEBP' + +fields = '' +j=1 +fields = fields // CMB_CL_Fields(j:j) + +end program tester -- 2.30.2