public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-9307] Fortran: fix scalarization for intrinsic LEN_TRIM with present KIND argument
Date: Wed, 24 Nov 2021 19:51:16 +0000 (GMT)	[thread overview]
Message-ID: <20211124195116.BF73A3857C71@sourceware.org> (raw)

https://gcc.gnu.org/g:3e6b9910e8e23d690fa1026b2879d37745ddd740

commit r11-9307-g3e6b9910e8e23d690fa1026b2879d37745ddd740
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Nov 23 17:51:38 2021 +0100

    Fortran: fix scalarization for intrinsic LEN_TRIM with present KIND argument
    
    gcc/fortran/ChangeLog:
    
            PR fortran/87711
            PR fortran/87851
            * trans-array.c (arg_evaluated_for_scalarization): Add LEN_TRIM to
            list of intrinsics for which an optional KIND argument needs to be
            removed before scalarization.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/87711
            PR fortran/87851
            * gfortran.dg/len_trim.f90: New test.
    
    (cherry picked from commit 721d8b9e26bf8205c1f2125c2626919a408cdbe4)

Diff:
---
 gcc/fortran/trans-array.c              |  1 +
 gcc/testsuite/gfortran.dg/len_trim.f90 | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index ea413d80ef1..db14daca459 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -11223,6 +11223,7 @@ arg_evaluated_for_scalarization (gfc_intrinsic_sym *function,
       switch (function->id)
 	{
 	  case GFC_ISYM_INDEX:
+	  case GFC_ISYM_LEN_TRIM:
 	    if ((actual_arg.name == NULL && arg_num == 3)
 		|| (actual_arg.name != NULL
 		    && strcmp ("kind", actual_arg.name) == 0))
diff --git a/gcc/testsuite/gfortran.dg/len_trim.f90 b/gcc/testsuite/gfortran.dg/len_trim.f90
new file mode 100644
index 00000000000..2252b81f084
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/len_trim.f90
@@ -0,0 +1,27 @@
+! { dg-do compile }
+! { dg-options "-O -Wall -Wconversion-extra -fdump-tree-original" }
+! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "original" } }
+! PR fortran/87711 - ICE in gfc_trans_transfer
+! PR fortran/87851 - return type for len_trim
+
+program main
+  implicit none
+  character(3), parameter :: a(1) = 'aa'
+  character(3)            :: b    = "bb"
+  character(3)            :: c(1) = 'cc'
+  integer(4), parameter   :: l4(1) = len_trim (a, kind=4)
+  integer(8), parameter   :: l8(1) = len_trim (a, kind=8)
+  integer                 :: kk(1) = len_trim (a)
+  integer(4)              :: mm(1) = len_trim (a, kind=4)
+  integer(8)              :: nn(1) = len_trim (a, kind=8)
+  kk = len_trim (a)
+  mm = len_trim (a, kind=4)
+  nn = len_trim (a, kind=8)
+  kk = len_trim ([b])
+  mm = len_trim ([b],kind=4)
+  nn = len_trim ([b],kind=8)
+  kk = len_trim (c)
+  mm = len_trim (c, kind=4)
+  nn = len_trim (c, kind=8)
+  if (any (l4 /= 2_4) .or. any (l8 /= 2_8)) stop 1
+end program main


                 reply	other threads:[~2021-11-24 19:51 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=20211124195116.BF73A3857C71@sourceware.org \
    --to=anlauf@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).