Fortran: Fix ICE in gfc_trans_pointer_assignment [PR113956]
2024-04-09 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/113956 * trans-expr.cc (gfc_trans_pointer_assignment): Remove assert causing the ICE since it was unnecesary. gcc/testsuite/ PR fortran/113956 * gfortran.dg/pr113956.f90: New test.
This commit is contained in:
parent
32fb04adae
commit
88aea122a7
2 changed files with 24 additions and 6 deletions
|
@ -10550,12 +10550,9 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2)
|
|||
{
|
||||
gfc_symbol *psym = expr1->symtree->n.sym;
|
||||
tmp = NULL_TREE;
|
||||
if (psym->ts.type == BT_CHARACTER)
|
||||
{
|
||||
gcc_assert (psym->ts.u.cl->backend_decl
|
||||
&& VAR_P (psym->ts.u.cl->backend_decl));
|
||||
tmp = psym->ts.u.cl->backend_decl;
|
||||
}
|
||||
if (psym->ts.type == BT_CHARACTER
|
||||
&& psym->ts.u.cl->backend_decl)
|
||||
tmp = psym->ts.u.cl->backend_decl;
|
||||
else if (expr1->ts.u.cl->backend_decl
|
||||
&& VAR_P (expr1->ts.u.cl->backend_decl))
|
||||
tmp = expr1->ts.u.cl->backend_decl;
|
||||
|
|
21
gcc/testsuite/gfortran.dg/pr113956.f90
Normal file
21
gcc/testsuite/gfortran.dg/pr113956.f90
Normal file
|
@ -0,0 +1,21 @@
|
|||
! { dg-do run }
|
||||
! Test the fix for PR113956
|
||||
! Contributed by David Binderman <dcb314@hotmail.com>
|
||||
module m
|
||||
contains
|
||||
subroutine test_array_char(p, x)
|
||||
character(*), target :: x(:)
|
||||
character(:), pointer :: p(:)
|
||||
p => x ! ICE
|
||||
end subroutine
|
||||
end module
|
||||
|
||||
use m
|
||||
character(:), allocatable, target :: chr(:)
|
||||
character(:), pointer :: p(:)
|
||||
chr = ["ab","cd"]
|
||||
call test_array_char (p, chr)
|
||||
if (loc (chr) .ne. loc (p)) stop 1
|
||||
if (len (p) .ne. 2) stop 2
|
||||
if (any (p .ne. chr)) stop 3
|
||||
end
|
Loading…
Add table
Reference in a new issue