[flang-commits] [flang] [flang][cuda] Propagate CUDA attrs from parent variable to component deallocs (PR #220059)

Zhen Wang via flang-commits flang-commits at lists.llvm.org
Mon Aug 31 12:46:29 PDT 2026


wangzpgi wrote:

Can you check whether the parent attribute overrides the component's own attribute here?

```fortran
module m
  type :: t
    real(8), device, allocatable :: d(:)
  end type
end module

subroutine s()
  use m
  type(t), managed, allocatable :: x(:)
  allocate(x(1))
  allocate(x(1)%d(10))
  deallocate(x(1)%d)
end subroutine
```

Here `d` has its own `device` attribute and the parent `x` is `managed`. The ALLOCATE uses `d`'s own attribute, since `genSimpleAllocation` only looks at the parent when the object has no attribute of its own. The new DEALLOCATE code looks at the parent first, so I think it would pick `managed` — allocating with one allocator and freeing with another.

Could both sides use the same precedence?

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


More information about the flang-commits mailing list