]> gcc.gnu.org Git - gcc.git/commitdiff
Patch and ChangeLogs for PR92976
authorPaul Thomas <pault@pc30.home>
Sun, 1 Mar 2020 16:15:28 +0000 (16:15 +0000)
committerPaul Thomas <pault@pc30.home>
Sun, 1 Mar 2020 16:15:28 +0000 (16:15 +0000)
gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/select_type_48.f90 [new file with mode: 0644]

index 39786ecf7cb630af4d448dd066bd2c35dc8a08a8..1256b95ae75c0055874cd3085c79fdb569f93920 100644 (file)
@@ -1,3 +1,9 @@
+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
index 17196eb1ae61f3202d73167af217ccd29c385bdc..753a5f1f1a4995f097c04de001ba5dad507b79b2 100644 (file)
@@ -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;
+               }
            }
        }
 
index 6ae4df78e276ad0c32351bec4da27caa4a79e924..fd3eeba994610dd0e6a5db47ff38c30fea6544c2 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/gfortran.dg/select_type_48.f90 b/gcc/testsuite/gfortran.dg/select_type_48.f90
new file mode 100644 (file)
index 0000000..d9ad01c
--- /dev/null
@@ -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
This page took 0.098227 seconds and 5 git commands to generate.