diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2024-04-09 15:23:46 +0100 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2024-04-09 15:23:46 +0100 |
commit | 88aea122a7ee639230bf17a9eda4bf8a5eb7e282 (patch) | |
tree | d14df3f34da6cddec634627ba3761b2d6c3fad9a | |
parent | 32fb04adae90a0ea68e64e8fc3cb04b613b2e9f3 (diff) | |
download | gcc-88aea122a7ee639230bf17a9eda4bf8a5eb7e282.zip gcc-88aea122a7ee639230bf17a9eda4bf8a5eb7e282.tar.gz gcc-88aea122a7ee639230bf17a9eda4bf8a5eb7e282.tar.bz2 |
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.
-rw-r--r-- | gcc/fortran/trans-expr.cc | 9 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr113956.f90 | 21 |
2 files changed, 24 insertions, 6 deletions
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index f4c4724..605434f 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -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; diff --git a/gcc/testsuite/gfortran.dg/pr113956.f90 b/gcc/testsuite/gfortran.dg/pr113956.f90 new file mode 100644 index 0000000..229e891 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr113956.f90 @@ -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 |