public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4736] Fortran: Fix 'select rank' for allocatables/pointers
@ 2021-10-27 9:00 Tobias Burnus
0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-10-27 9:00 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7f899b23f36f94f907a025d3eeaf3e4640544927
commit r12-4736-g7f899b23f36f94f907a025d3eeaf3e4640544927
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Wed Oct 27 10:59:27 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.
Diff:
---
gcc/fortran/trans-stmt.c | 2 +-
gcc/testsuite/gfortran.dg/PR93963.f90 | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index c66a3bee83e..eaf2cc25f21 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/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" } }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-27 9:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 9:00 [gcc r12-4736] Fortran: Fix 'select rank' for allocatables/pointers Tobias Burnus
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).