Skip to content

[flang] Ensure overrides of special procedures #142465

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
Jun 10, 2025
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
4 changes: 2 additions & 2 deletions flang/lib/Semantics/runtime-type-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ RuntimeTableBuilder::DescribeSpecialGenerics(const Scope &dtScope,
specials =
DescribeSpecialGenerics(*parentScope, thisScope, derivedTypeSpec);
}
for (auto pair : dtScope) {
for (const auto &pair : dtScope) {
const Symbol &symbol{*pair.second};
if (const auto *generic{symbol.detailsIf<GenericDetails>()}) {
DescribeSpecialGeneric(*generic, specials, thisScope, derivedTypeSpec);
Expand Down Expand Up @@ -1241,7 +1241,7 @@ void RuntimeTableBuilder::DescribeSpecialProc(
AddValue(values, specialSchema_, procCompName,
SomeExpr{evaluate::ProcedureDesignator{specific}});
// index might already be present in the case of an override
specials.emplace(*index,
specials.insert_or_assign(*index,
evaluate::StructureConstructor{
DEREF(specialSchema_.AsDerived()), std::move(values)});
}
Expand Down
26 changes: 26 additions & 0 deletions flang/test/Semantics/typeinfo13.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
!RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
!Ensure ASSIGNMENT(=) overrides are applied to the special procedures table.
module m
type base
contains
procedure :: baseAssign
generic :: assignment(=) => baseAssign
end type
type, extends(base) :: child
contains
procedure :: override
generic :: assignment(=) => override
end type
contains
impure elemental subroutine baseAssign(to, from)
class(base), intent(out) :: to
type(base), intent(in) :: from
end
impure elemental subroutine override(to, from)
class(child), intent(out) :: to
type(child), intent(in) :: from
end
end

!CHECK: .s.child, SAVE, TARGET (CompilerCreated, ReadOnly): ObjectEntity type: TYPE(specialbinding) shape: 0_8:0_8 init:[specialbinding::specialbinding(which=2_1,isargdescriptorset=1_1,istypebound=1_1,isargcontiguousset=0_1,proc=override)]
!CHECK: .v.child, SAVE, TARGET (CompilerCreated, ReadOnly): ObjectEntity type: TYPE(binding) shape: 0_8:1_8 init:[binding::binding(proc=baseassign,name=.n.baseassign),binding(proc=override,name=.n.override)]
Loading