Fortran: fix ICE in generate_coarray_sym_init [PR82868]

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.
This commit is contained in:
Harald Anlauf 2022-09-21 19:55:30 +02:00
parent 3ad3f53bb3
commit bc71318a91
2 changed files with 16 additions and 0 deletions

View 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;

View file

@ -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