[flang-commits] [flang] [Flang] Remove redundant check for CrayPointer (PR #123171)

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Thu Jan 16 09:53:46 PST 2025


DanielCChen wrote:


  

> > I have a doubt,
> > Consider an example
> > ```fortran
> > program test
> > real :: pte(*)
> > ! pointer(pte, ptr)
> > end program
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > For which, `pte` would be assumed rank array unless we use `pointer(pte, ptr)` to create `CrayPointer` and mark `pte` as `CrayPointee`. Is my understanding correct?
> > @jeanPerier @tblah @kiranchandramohan
> 
> I am not very familiar with Cray pointers. Would @DanielCChen or @kkwli know?

The example code is not standard conforming. 
If I have to guess, `real :: pte(*)` is trying to declare a rank-1 assumed-size dummy argument, `pte`. 
A CrayPointer is just a C pointer. It only represents address of its pointee. 

I modified the code to make it executable and hopefully it will illustrate how CrayPointer works.
```
real :: arr(10)
arr = 10
call sub(arr)
contains
subroutine sub(pte)
  real :: pte(*)
  real :: local(10)
  pointer (ptr, local)
  ptr = loc(pte)
  print*, local
end
end
```



https://github.com/llvm/llvm-project/pull/123171


More information about the flang-commits mailing list