]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: fix ICE in generate_coarray_sym_init [PR82868]
authorHarald Anlauf <anlauf@gmx.de>
Wed, 21 Sep 2022 17:55:30 +0000 (19:55 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Thu, 29 Sep 2022 18:35:45 +0000 (20:35 +0200)
gcc/fortran/ChangeLog:

PR fortran/82868
* trans-decl.cc (generate_coarray_sym_init): Skip symbol
if attr.associate_var.

gcc/testsuite/ChangeLog:

PR fortran/82868
* gfortran.dg/associate_26a.f90: New test.

(cherry picked from commit bc71318a91286b5f00e88f07aab818ac82510692)

gcc/fortran/trans-decl.cc
gcc/testsuite/gfortran.dg/associate_26a.f90 [new file with mode: 0644]

index 908a4c6d42eac703c2b23d0c81a0f117dfd0fb19..5d16d64032268abf03ac21b9c306ea7b84e50850 100644 (file)
@@ -5529,6 +5529,7 @@ generate_coarray_sym_init (gfc_symbol *sym)
 
   if (sym->attr.dummy || sym->attr.allocatable || !sym->attr.codimension
       || sym->attr.use_assoc || !sym->attr.referenced
+      || sym->attr.associate_var
       || sym->attr.select_type_temporary)
     return;
 
diff --git a/gcc/testsuite/gfortran.dg/associate_26a.f90 b/gcc/testsuite/gfortran.dg/associate_26a.f90
new file mode 100644 (file)
index 0000000..85aebeb
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+!
+! Test the fix for PR78152 and the followup in PR82868
+!
+! Contributed by <physiker@toast2.net>
+!
+program co_assoc
+  implicit none
+  integer, parameter :: p = 5
+  real, allocatable :: a(:,:)[:,:]
+  allocate (a(p,p)[2,*])
+  associate (i => a(1:p, 1:p))
+  end associate
+end program co_assoc