public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-9873] Fortran: Fix ICE in gfc_trans_pointer_assignment [PR113956]
@ 2024-04-09 14:23 Paul Thomas
  0 siblings, 0 replies; only message in thread
From: Paul Thomas @ 2024-04-09 14:23 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:88aea122a7ee639230bf17a9eda4bf8a5eb7e282

commit r14-9873-g88aea122a7ee639230bf17a9eda4bf8a5eb7e282
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Tue Apr 9 15:23:46 2024 +0100

    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.

Diff:
---
 gcc/fortran/trans-expr.cc              |  9 +++------
 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 f4c4724e1c3..605434f4ddb 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 00000000000..229e891f847
--- /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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-09 14:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 14:23 [gcc r14-9873] Fortran: Fix ICE in gfc_trans_pointer_assignment [PR113956] Paul Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).