re PR fortran/85521 (ICE in gfc_resolve_character_array_constructor, at fortran/array...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 10 May 2018 22:45:38 +0000 (22:45 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 10 May 2018 22:45:38 +0000 (22:45 +0000)
2018-05-10  Steven G. Kargl  <kargl@gcc.gnu.org>

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  <kargl@gcc.gnu.org>

PR fortran/85521
* gfortran.dg/pr85521_1.f90: New test.
* gfortran.dg/pr85521_2.f90: New test.

From-SVN: r260139

gcc/fortran/ChangeLog
gcc/fortran/array.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr85521_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr85521_2.f90 [new file with mode: 0644]

index aedcb2d96084e497c6f4ab92f375e9b9124f5bf1..09d015c12ba14d637bed34d96054c6e0162cb9e6 100644 (file)
@@ -1,3 +1,9 @@
+2018-05-10  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       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  <kargl@gcc.gnu.org>
 
        PR fortran/70870
index 58d611ba4f57307d36a15dc6fdd5b6e5baa8705e..052775f0bafbffb027f2e9cbc57167dd8c9f2416 100644 (file)
@@ -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;
index 64014c4858544f1eed58d090f5e42f74477909ea..73f74e0840138154087810abbb07e306319493b4 100644 (file)
@@ -1,3 +1,9 @@
+2018-05-10  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/85521
+       * gfortran.dg/pr85521_1.f90: New test.
+       * gfortran.dg/pr85521_2.f90: New test.
+
 2018-05-10  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        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 (file)
index 0000000..57e4620
--- /dev/null
@@ -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 (file)
index 0000000..737b61a
--- /dev/null
@@ -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