aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaul Thomas <pault@pc30.home>2020-03-01 16:15:28 +0000
committerPaul Thomas <pault@pc30.home>2020-03-01 16:15:28 +0000
commit957a1b14e99596610abb0777ca86a1c80dde24e0 (patch)
tree1e0fb5c91094e6f4c4f63b4260bc391845fbd096 /gcc
parent12caab4fb19dcbea25a140652da4f5ca439af7c5 (diff)
downloadgcc-957a1b14e99596610abb0777ca86a1c80dde24e0.zip
gcc-957a1b14e99596610abb0777ca86a1c80dde24e0.tar.gz
gcc-957a1b14e99596610abb0777ca86a1c80dde24e0.tar.bz2
Patch and ChangeLogs for PR92976
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/match.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/select_type_48.f9031
4 files changed, 50 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 39786ec..1256b95 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
2020-03-01 Paul Thomas <pault@gcc.gnu.org>
+ PR fortran/92976
+ * match.c (select_type_set_tmp): If the selector array spec has
+ explicit bounds, make the temporary's bounds deferred.
+
+2020-03-01 Paul Thomas <pault@gcc.gnu.org>
+
PR fortran/92959
* trans-intrinsic.c (gfc_conv_associated): Eliminate
'nonzero_charlen' and move the chunk to evaluate zero character
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 17196eb..753a5f1 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -6327,8 +6327,14 @@ select_type_set_tmp (gfc_typespec *ts)
= CLASS_DATA (selector)->attr.dimension;
sym->attr.codimension
= CLASS_DATA (selector)->attr.codimension;
- sym->as
- = gfc_copy_array_spec (CLASS_DATA (selector)->as);
+ if (CLASS_DATA (selector)->as->type != AS_EXPLICIT)
+ sym->as = gfc_copy_array_spec (CLASS_DATA (selector)->as);
+ else
+ {
+ sym->as = gfc_get_array_spec();
+ sym->as->rank = CLASS_DATA (selector)->as->rank;
+ sym->as->type = AS_DEFERRED;
+ }
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6ae4df7..fd3eeba 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2020-03-01 Paul Thomas <pault@gcc.gnu.org>
+ PR fortran/92976
+ * gfortran.dg/select_type_48.f90 : New test.
+
+2020-03-01 Paul Thomas <pault@gcc.gnu.org>
+
PR fortran/92959
* gfortran.dg/associated_8.f90 : New test.
diff --git a/gcc/testsuite/gfortran.dg/select_type_48.f90 b/gcc/testsuite/gfortran.dg/select_type_48.f90
new file mode 100644
index 0000000..d9ad01c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/select_type_48.f90
@@ -0,0 +1,31 @@
+! { dg-do run }
+!
+! Test the fix for PR92976, in which the TYPE IS statement caused an ICE
+! because of the explicit bounds of 'x'.
+!
+! Contributed by Gerhard Steinmetz <gscfq@t-online.de>
+!
+program p
+ type t
+ integer :: i
+ end type
+ class(t), allocatable :: c(:)
+ allocate (c, source = [t(1111),t(2222),t(3333)])
+ call s(c)
+ if (sum (c%i) .ne. 3333) stop 1
+contains
+ subroutine s(x)
+ class(t) :: x(2)
+ select type (x)
+! ICE as compiler attempted to assign descriptor to an array
+ type is (t)
+ x%i = 0
+! Make sure that bounds are correctly translated.
+ call counter (x)
+ end select
+ end
+ subroutine counter (arg)
+ type(t) :: arg(:)
+ if (size (arg, 1) .ne. 2) stop 2
+ end
+end