[flang-commits] [flang] [flang][RFC] Adding a design document for assumed-rank objects (PR #71959)
via flang-commits
flang-commits at lists.llvm.org
Mon Nov 13 10:15:09 PST 2023
================
@@ -0,0 +1,632 @@
+<!--===- docs/AssumedRank.md
+
+ Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ See https://llvm.org/LICENSE.txt for license information.
+ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+-->
+# Assumed-Rank Objects
+
+An assumed-rank is a data object that takes its rank from its effective
+argument. It is a dummy, or the associated entity of a SELECT RANK in the `RANK
+DEFAULT` or `RANK(*)` blocks. Its rank is not known at compile time. The rank
----------------
jeanPerier wrote:
> I seems best to change the rank to 1 at the first call;
I agree but is it legal?
I think this would prevent `RANK(x)` to return the rank of the effective argument of the assumed rank as requested by the standard (there is no special case for assumed-rank associated with assumed-size in RANK(), nor in 8.5.8.7).
UBOUND and al. also does not say that an assumed-rank associated to an assumed-size has rank one (only mention a special case for the "final dimension").
I think we can only change it in the RANK(*), even if it makes all SELECT RANK checking a bit more expensive (especially since we must not fall in RANK(cst) for an assumed-size even if there is not RANK(*)).
All other compilers that can compile the program below seem to keep the rank of the assumed-size attached to the assumed-rank:
````
module m
contains
subroutine print_my_rank(x)
real :: x(..)
print *, rank(x)
end subroutine
subroutine test(x1, x2, x3)
real :: x1(*)
real :: x2(1, *)
real :: x3(1, 1, *)
call print_my_rank(x1)
call print_my_rank(x2)
call print_my_rank(x3)
end subroutine
end module
use m
real :: x1(1)
real :: x2(1, 1)
real :: x3(1, 1, 1)
call test(x1, x2, x3)
end
```
Prints "1,2,3".
https://github.com/llvm/llvm-project/pull/71959
More information about the flang-commits
mailing list