]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/85521 (ICE in gfc_resolve_character_array_constructor, at fortran/array...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 11 May 2018 18:34:14 +0000 (18:34 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 11 May 2018 18:34:14 +0000 (18:34 +0000)
2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/85521
Backport from trunk
* array.c (gfc_resolve_character_array_constructor): Substrings
with upper bound smaller than lower bound are zero length strings.

2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>

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

From-SVN: r260180

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 38c5891c64155fc861aeded191a379af29d9f78a..cdbb6574f4b300ebb7db15a8afe1c87999f49613 100644 (file)
@@ -1,3 +1,10 @@
+2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/85521
+       Backport from trunk
+       * array.c (gfc_resolve_character_array_constructor): Substrings
+       with upper bound smaller than lower bound are zero length strings.
+
 2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/85687
index b87e85559727c8d8ab723a4f60ba91791485962d..29f96d9d6d5c3b50d169d6376dc2124a06ca765d 100644 (file)
@@ -2018,7 +2018,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 edfc2c4970fdcfd306be178dd5fa96e29bfe815a..0d0ae553c128979ce784c14d8dce59cf4d3ab671 100644 (file)
@@ -1,3 +1,10 @@
+2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/85521
+       Backport from trunk
+       * gfortran.dg/pr85521_1.f90: New test.
+       * gfortran.dg/pr85521_2.f90: New test.
+
 2018-05-11  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/85687
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