public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-11] Fortran: Fix 'select rank' for allocatables/pointers
Date: Wed, 27 Oct 2021 09:17:23 +0000 (GMT)	[thread overview]
Message-ID: <20211027091723.C5D303858436@sourceware.org> (raw)

https://gcc.gnu.org/g:4684807c25b2be1979e8d5301aa273fa6bf06b9d

commit 4684807c25b2be1979e8d5301aa273fa6bf06b9d
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Wed Oct 27 11:01:56 2021 +0200

    Fortran: Fix 'select rank' for allocatables/pointers
    
    gcc/fortran/ChangeLog:
    
            * trans-stmt.c (gfc_trans_select_rank_cases): Fix condition
            for allocatables/pointers.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/PR93963.f90: Extend testcase by scan-tree-dump test.
    
    (cherry picked from commit 7f899b23f36f94f907a025d3eeaf3e4640544927)

Diff:
---
 gcc/fortran/ChangeLog.omp             | 8 ++++++++
 gcc/fortran/trans-stmt.c              | 2 +-
 gcc/testsuite/ChangeLog.omp           | 7 +++++++
 gcc/testsuite/gfortran.dg/PR93963.f90 | 5 +++++
 4 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index c1f975072c0..894ca5c78e4 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,11 @@
+2021-10-27  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backport from master:
+	2021-10-27  Tobias Burnus  <tobias@codesourcery.com>
+
+	* trans-stmt.c (gfc_trans_select_rank_cases): Fix condition
+	for allocatables/pointers.
+
 2021-10-26  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backport from master:
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 64b0529d8b8..5f576424fc3 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -3685,7 +3685,7 @@ gfc_trans_select_rank_cases (gfc_code * code)
   rank = gfc_conv_descriptor_rank (se.expr);
   rank = gfc_evaluate_now (rank, &block);
   symbol_attribute attr = gfc_expr_attr (code->expr1);
-  if (!attr.pointer || !attr.allocatable)
+  if (!attr.pointer && !attr.allocatable)
     {
       /* Special case for assumed-rank ('rank(*)', internally -1):
 	 rank = (rank == 0 || ubound[rank-1] != -1) ? rank : -1.  */
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 2184865b8d9..4e978deeff1 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,10 @@
+2021-10-27  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backport from master:
+	2021-10-27  Tobias Burnus  <tobias@codesourcery.com>
+
+	* gfortran.dg/PR93963.f90: Extend testcase by scan-tree-dump test.
+
 2021-10-27  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/gfortran.dg/PR93963.f90 b/gcc/testsuite/gfortran.dg/PR93963.f90
index 66c937974ac..6769d7fe061 100644
--- a/gcc/testsuite/gfortran.dg/PR93963.f90
+++ b/gcc/testsuite/gfortran.dg/PR93963.f90
@@ -1,4 +1,5 @@
 ! { dg-do run }
+! { dg-additional-options "-fdump-tree-original" }
 !
 ! Test the fix for PR93963
 !
@@ -190,3 +191,7 @@ program selr_p
   deallocate(inta)
 
 end program selr_p
+
+! Special code for assumed rank - but only if not allocatable/pointer
+! Thus, expect it only once for subroutine rank_o but not for rank_a or rank_p
+! { dg-final { scan-tree-dump-times "ubound != -1" 1 "original" } }


                 reply	other threads:[~2021-10-27  9:17 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=20211027091723.C5D303858436@sourceware.org \
    --to=burnus@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).