[flang] Retrieve rank before updating the pointer
authorValentin Clement <clementval@gmail.com>
Mon, 5 Dec 2022 17:26:16 +0000 (18:26 +0100)
committerValentin Clement <clementval@gmail.com>
Mon, 5 Dec 2022 17:27:19 +0000 (18:27 +0100)
commit87dfec9dc8991a9a14df3ce3443da296354b5d57
tree80d69aa4f390f64b9044efd7dc16ade5c6501a0f
parent2b6683fd5f7481d57a29ca6c5cd68822e1cfe5b0
[flang] Retrieve rank before updating the pointer

The code is iterating on the rank of the pointer to set the bounds.
If the rank is retrieved after the `pointer = target` it does not
reflect the actual rank of the pointer.

This could happen in code like the following:

```
type t1
  integer :: a
end type

type(t), pointer :: p(:)
class(t), pointer :: q(:,:)
q(0:1,-2:2) => p(10:1:-1)
```

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D139327
flang/runtime/pointer.cpp