Apply the source type spec to the descriptor for
polyrmophic entities.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Questions about some edge cases, the rest looks good.
flang/lib/Lower/Allocatable.cpp | ||
---|---|---|
560 | Is it possible for the sourceExpr->GetType() to be null ? Is it also possible that the source be an unlimited polymorphic if the allocatable object also is one ? subroutine foo(any, any_source) class(*), allocatable :: any class(*), pointer :: any_source allocate(any, source = any_source) end subroutine (If so, this will probably require some custom runtime entry point, and it's fine to leave a TODO at first). |
Simplify condition + add test for unlimited polymorphic allocation from
unlimited polyrmophic source.
flang/lib/Lower/Allocatable.cpp | ||
---|---|---|
560 | I believe sourceExpr->GetType() is always defined. It is possible to have an unlimited polymorphic source to allocate an unlimited polymorphic source. This falls in the TypeCategory::Derived category as unlimited polymorphic descriptor are defined as DerivedType in the frontend. |
flang/lib/Lower/Allocatable.cpp | ||
---|---|---|
560 | But what if the unlimited polymorphic dynamic type is an intrinsic type and not a derived type (say any_source is pointing to an integer). Is it correct to call genInitDerived in that case ? | |
560 |
Ok, makes sense. I was not sure. However, I remember that in some rare semantics bugs, it happened that GetType() returned null (because something failed in expression resolution and was not correctly reported), so I would tend add asserts when using that (or using the DEREF() front end macro). |
- Add a TODO for unlimited polymoprhic source and allocate object
- Add an assert for GetType()
Other than some clang-format diffs, all builds and tests correctly and looks good.
flang/lib/Lower/Allocatable.cpp | ||
---|---|---|
552–557 | I get clang-format diffs here. | |
603 | For some reason this comment generates a clang-format diff. | |
610–614 | More clang-format diffs here. | |
622–626 | More clang-format diffs here. | |
652–656 | More clang-format diffs. |
flang/lib/Lower/Allocatable.cpp | ||
---|---|---|
552–557 | I guess it was before the last update. Pre-commit check is clean right now. |
I get clang-format diffs here.