Skip to content

[flang] Revert two new interoperability semantic checks #93112

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
May 23, 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
36 changes: 0 additions & 36 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2960,32 +2960,6 @@ parser::Messages CheckHelper::WhyNotInteroperableDerivedType(
return msgs;
}

static UnorderedSymbolSet CollectEntryPointsWithDummy(const Symbol &dummy) {
UnorderedSymbolSet entries;
const Scope &subpScope{dummy.owner()};
for (const auto &[_, ref] : subpScope.parent()) {
const Symbol &x{*ref};
if (const auto *subp{x.detailsIf<SubprogramDetails>()}) {
if (x.scope() == &subpScope || subp->entryScope() == &dummy.owner()) {
if (std::find(subp->dummyArgs().begin(), subp->dummyArgs().end(),
&dummy) != subp->dummyArgs().end()) {
entries.insert(x);
}
}
}
}
return entries;
}

static bool AnyNonBindCEntry(const Symbol &dummy) {
for (const Symbol &subp : CollectEntryPointsWithDummy(dummy)) {
if (!subp.attrs().test(Attr::BIND_C)) {
return true;
}
}
return false;
}

parser::Messages CheckHelper::WhyNotInteroperableObject(
const Symbol &symbol, bool isError) {
parser::Messages msgs;
Expand Down Expand Up @@ -3049,10 +3023,6 @@ parser::Messages CheckHelper::WhyNotInteroperableObject(
}
if (type->IsAssumedType()) { // ok
} else if (IsAssumedLengthCharacter(symbol)) {
if (AnyNonBindCEntry(symbol)) {
msgs.Say(symbol.name(),
"An assumed-length dummy argument must not appear in a non-BIND(C) entry in a subprogram with an entry that must be interoperable"_err_en_US);
}
} else if (IsAllocatableOrPointer(symbol) &&
type->category() == DeclTypeSpec::Character &&
type->characterTypeSpec().length().isDeferred()) {
Expand Down Expand Up @@ -3083,12 +3053,6 @@ parser::Messages CheckHelper::WhyNotInteroperableObject(
msgs.Say(symbol.name(),
"An interoperable procedure with an OPTIONAL dummy argument might not be portable"_port_en_US);
}
if (symbol.attrs().test(Attr::VALUE)) {
if (AnyNonBindCEntry(symbol)) {
msgs.Say(symbol.name(),
"A VALUE dummy argument must not appear in a non-BIND(C) entry of a subprogram with an entry that must be interoperable"_err_en_US);
}
}
if (IsDescriptor(symbol) && IsPointer(symbol) &&
symbol.attrs().test(Attr::CONTIGUOUS)) {
msgs.Say(symbol.name(),
Expand Down
4 changes: 2 additions & 2 deletions flang/test/Semantics/bind-c12.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ subroutine p(n)

subroutine subr5(p) bind(c)
interface
!WARNING: A dummy procedure of an interoperable procedure should be BIND(C)
subroutine p(c)
!ERROR: An assumed-length dummy argument must not appear in a non-BIND(C) entry in a subprogram with an entry that must be interoperable
character(*), intent(in) :: c
end
end interface
Expand All @@ -52,8 +52,8 @@ character(*) function p()

subroutine subr8(p) bind(c)
interface
!WARNING: A dummy procedure of an interoperable procedure should be BIND(C)
subroutine p(n)
!ERROR: A VALUE dummy argument must not appear in a non-BIND(C) entry of a subprogram with an entry that must be interoperable
integer, intent(in), value :: n
end
end interface
Expand Down
Loading