Skip to content

[flang] ensure parent component are first in runtime type info #81259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions flang/lib/Semantics/runtime-type-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,11 @@ const Symbol *RuntimeTableBuilder::DescribeType(Scope &dtScope) {
},
symbol.details());
}
// Sort the data component symbols by offset before emitting them
// Sort the data component symbols by offset before emitting them, placing
// the parent component first if any.
std::sort(dataComponentSymbols.begin(), dataComponentSymbols.end(),
[](const Symbol *x, const Symbol *y) {
return x->offset() < y->offset();
return x->test(Symbol::Flag::ParentComp) || x->offset() < y->offset();
});
std::vector<evaluate::StructureConstructor> dataComponents;
for (const Symbol *symbol : dataComponentSymbols) {
Expand Down
14 changes: 14 additions & 0 deletions flang/test/Semantics/typeinfo10.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
!RUN: bbc --dump-symbols %s | FileCheck %s
!RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s

! Test that empty parent types are still set first in the
! runtime info global array describing components.
module empty_parent
type :: z
end type

type, extends(z) :: t
integer :: a
end type
end module
! CHECK: .c.t, SAVE{{.*}}.n.z{{.*}}n.a