public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Paul Thomas <pault@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-9873] Fortran: Fix ICE in gfc_trans_pointer_assignment [PR113956]
Date: Tue,  9 Apr 2024 14:23:56 +0000 (GMT)	[thread overview]
Message-ID: <20240409142356.F0FED3858C39@sourceware.org> (raw)

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

                 reply	other threads:[~2024-04-09 14:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240409142356.F0FED3858C39@sourceware.org \
    --to=pault@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).