From: Steven G. Kargl Date: Thu, 10 May 2018 22:45:38 +0000 (+0000) Subject: re PR fortran/85521 (ICE in gfc_resolve_character_array_constructor, at fortran/array... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=14ee7de064f757c7677b906010f7e67e702b62c7;p=gcc.git re PR fortran/85521 (ICE in gfc_resolve_character_array_constructor, at fortran/array.c:2049) 2018-05-10 Steven G. Kargl PR fortran/85521 * array.c (gfc_resolve_character_array_constructor): Substrings with upper bound smaller than lower bound are zero length strings. 2018-05-10 Steven G. Kargl PR fortran/85521 * gfortran.dg/pr85521_1.f90: New test. * gfortran.dg/pr85521_2.f90: New test. From-SVN: r260139 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index aedcb2d9608..09d015c12ba 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-05-10 Steven G. Kargl + + PR fortran/85521 + * array.c (gfc_resolve_character_array_constructor): Substrings + with upper bound smaller than lower bound are zero length strings. + 2018-05-10 Steven G. Kargl PR fortran/70870 diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 58d611ba4f5..052775f0baf 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -2046,7 +2046,8 @@ got_charlen: else return true; - gcc_assert (current_length != -1); + if (current_length < 0) + current_length = 0; if (found_length == -1) found_length = current_length; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 64014c48585..73f74e08401 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-05-10 Steven G. Kargl + + PR fortran/85521 + * gfortran.dg/pr85521_1.f90: New test. + * gfortran.dg/pr85521_2.f90: New test. + 2018-05-10 Steven G. Kargl PR fortran/70870 diff --git a/gcc/testsuite/gfortran.dg/pr85521_1.f90 b/gcc/testsuite/gfortran.dg/pr85521_1.f90 new file mode 100644 index 00000000000..57e4620fe0d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr85521_1.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/85521 +program p + character(3) :: c = 'abc' + character(3) :: z(1) + z = [ c(:-1) ] + print *, z +end diff --git a/gcc/testsuite/gfortran.dg/pr85521_2.f90 b/gcc/testsuite/gfortran.dg/pr85521_2.f90 new file mode 100644 index 00000000000..737b61a11b9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr85521_2.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/85521 +program p + character(3) :: c = 'abc' + character(3) :: z(1) + z = [ c(:-2) ] + print *, z +end