diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2021-10-27 10:59:27 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2021-10-27 10:59:27 +0200 |
commit | 7f899b23f36f94f907a025d3eeaf3e4640544927 (patch) | |
tree | c27dda6573c88324d1556d89b80255f005a1a66b /gcc | |
parent | 4f1fe0dc25391a1d73c1034a85b3b6bf04c5e26e (diff) | |
download | gcc-7f899b23f36f94f907a025d3eeaf3e4640544927.zip gcc-7f899b23f36f94f907a025d3eeaf3e4640544927.tar.gz gcc-7f899b23f36f94f907a025d3eeaf3e4640544927.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/trans-stmt.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/PR93963.f90 | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index c66a3be..eaf2cc2 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 66c9379..6769d7f 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" } } |