llvm-project
9c7e203b - [flang] Fix ignore_tkr(c) passing descriptor instead of base address for non-descriptor dummies (#186894)

Commit
1 day ago
[flang] Fix ignore_tkr(c) passing descriptor instead of base address for non-descriptor dummies (#186894) When ignore_tkr(c) is set and the actual argument is an allocatable or pointer (stored as a descriptor), the lowering code was unconditionally returning the descriptor pointer as-is, regardless of whether the dummy argument expects a descriptor. For bind(c) interfaces with assumed-size dummies (e.g., cuFFT), the dummy expects a raw pointer, not a descriptor. Passing the descriptor caused the C function to receive the wrong address, leading to silent data corruption and invalid descriptor crashes at deallocation. The fix adds a check that the early return for ignore_tkr(c) only applies when the dummy type is itself a descriptor type. When the dummy expects a base address, the normal path is taken, which correctly extracts the base address from the descriptor via fir.box_addr.
Author
Parents
Loading