Skip to content

Commit e2a3880

Browse files
authored
[flang] Revert two new interoperability semantic checks (#93112)
Two checks related to BIND(C) vs non-BIND(C) entry points with the same dummy argument added by #92474 have turned out to be unnecessary. Revert them and adjust the tests.
1 parent 79c2a1e commit e2a3880

File tree

2 files changed

+2
-38
lines changed

2 files changed

+2
-38
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,32 +2962,6 @@ parser::Messages CheckHelper::WhyNotInteroperableDerivedType(
29622962
return msgs;
29632963
}
29642964

2965-
static UnorderedSymbolSet CollectEntryPointsWithDummy(const Symbol &dummy) {
2966-
UnorderedSymbolSet entries;
2967-
const Scope &subpScope{dummy.owner()};
2968-
for (const auto &[_, ref] : subpScope.parent()) {
2969-
const Symbol &x{*ref};
2970-
if (const auto *subp{x.detailsIf<SubprogramDetails>()}) {
2971-
if (x.scope() == &subpScope || subp->entryScope() == &dummy.owner()) {
2972-
if (std::find(subp->dummyArgs().begin(), subp->dummyArgs().end(),
2973-
&dummy) != subp->dummyArgs().end()) {
2974-
entries.insert(x);
2975-
}
2976-
}
2977-
}
2978-
}
2979-
return entries;
2980-
}
2981-
2982-
static bool AnyNonBindCEntry(const Symbol &dummy) {
2983-
for (const Symbol &subp : CollectEntryPointsWithDummy(dummy)) {
2984-
if (!subp.attrs().test(Attr::BIND_C)) {
2985-
return true;
2986-
}
2987-
}
2988-
return false;
2989-
}
2990-
29912965
parser::Messages CheckHelper::WhyNotInteroperableObject(
29922966
const Symbol &symbol, bool isError) {
29932967
parser::Messages msgs;
@@ -3048,10 +3022,6 @@ parser::Messages CheckHelper::WhyNotInteroperableObject(
30483022
}
30493023
if (type->IsAssumedType()) { // ok
30503024
} else if (IsAssumedLengthCharacter(symbol)) {
3051-
if (AnyNonBindCEntry(symbol)) {
3052-
msgs.Say(symbol.name(),
3053-
"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);
3054-
}
30553025
} else if (IsAllocatableOrPointer(symbol) &&
30563026
type->category() == DeclTypeSpec::Character &&
30573027
type->characterTypeSpec().length().isDeferred()) {
@@ -3082,12 +3052,6 @@ parser::Messages CheckHelper::WhyNotInteroperableObject(
30823052
msgs.Say(symbol.name(),
30833053
"An interoperable procedure with an OPTIONAL dummy argument might not be portable"_port_en_US);
30843054
}
3085-
if (symbol.attrs().test(Attr::VALUE)) {
3086-
if (AnyNonBindCEntry(symbol)) {
3087-
msgs.Say(symbol.name(),
3088-
"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);
3089-
}
3090-
}
30913055
if (IsDescriptor(symbol) && IsPointer(symbol) &&
30923056
symbol.attrs().test(Attr::CONTIGUOUS)) {
30933057
msgs.Say(symbol.name(),

flang/test/Semantics/bind-c12.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ subroutine p(n)
2626

2727
subroutine subr5(p) bind(c)
2828
interface
29+
!WARNING: A dummy procedure of an interoperable procedure should be BIND(C)
2930
subroutine p(c)
30-
!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
3131
character(*), intent(in) :: c
3232
end
3333
end interface
@@ -52,8 +52,8 @@ character(*) function p()
5252

5353
subroutine subr8(p) bind(c)
5454
interface
55+
!WARNING: A dummy procedure of an interoperable procedure should be BIND(C)
5556
subroutine p(n)
56-
!ERROR: A VALUE dummy argument must not appear in a non-BIND(C) entry of a subprogram with an entry that must be interoperable
5757
integer, intent(in), value :: n
5858
end
5959
end interface

0 commit comments

Comments
 (0)