Skip to content

Commit d6f314c

Browse files
authored
[flang] Accept IGNORE_TKR in separate module procedure interface (#98374)
We emit an incorrect error message when !DIR$ IGNORE_TKR appears in a separate module procedure's interface declaration. Fixes #98210.
1 parent d5285fe commit d6f314c

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -762,13 +762,10 @@ void CheckHelper::CheckObjectEntity(
762762
}
763763
if (auto ignoreTKR{GetIgnoreTKR(symbol)}; !ignoreTKR.empty()) {
764764
const Symbol *ownerSymbol{symbol.owner().symbol()};
765-
const auto *ownerSubp{ownerSymbol->detailsIf<SubprogramDetails>()};
766-
bool inInterface{ownerSubp && ownerSubp->isInterface()};
767-
bool inExplicitInterface{
768-
inInterface && !IsSeparateModuleProcedureInterface(ownerSymbol)};
769-
bool inModuleProc{
770-
!inInterface && ownerSymbol && IsModuleProcedure(*ownerSymbol)};
771-
if (!inExplicitInterface && !inModuleProc) {
765+
bool inModuleProc{ownerSymbol && IsModuleProcedure(*ownerSymbol)};
766+
bool inExplicitExternalInterface{
767+
InInterface() && !IsSeparateModuleProcedureInterface(ownerSymbol)};
768+
if (!InInterface() && !inModuleProc) {
772769
messages_.Say(
773770
"!DIR$ IGNORE_TKR may apply only in an interface or a module procedure"_err_en_US);
774771
}
@@ -779,7 +776,7 @@ void CheckHelper::CheckObjectEntity(
779776
}
780777
if (IsPassedViaDescriptor(symbol)) {
781778
if (IsAllocatableOrObjectPointer(&symbol)) {
782-
if (inExplicitInterface) {
779+
if (inExplicitExternalInterface) {
783780
if (context_.ShouldWarn(common::UsageWarning::IgnoreTKRUsage)) {
784781
WarnIfNotInModuleFile(
785782
"!DIR$ IGNORE_TKR should not apply to an allocatable or pointer"_warn_en_US);
@@ -794,7 +791,7 @@ void CheckHelper::CheckObjectEntity(
794791
WarnIfNotInModuleFile(
795792
"!DIR$ IGNORE_TKR(R) is not meaningful for an assumed-rank array"_warn_en_US);
796793
}
797-
} else if (inExplicitInterface) {
794+
} else if (inExplicitExternalInterface) {
798795
if (context_.ShouldWarn(common::UsageWarning::IgnoreTKRUsage)) {
799796
WarnIfNotInModuleFile(
800797
"!DIR$ IGNORE_TKR(R) should not apply to a dummy argument passed via descriptor"_warn_en_US);

flang/test/Semantics/ignore_tkr01.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ subroutine t14(x)
9292
real x(:)
9393
end
9494

95+
module subroutine t24(x)
96+
!dir$ ignore_tkr(t) x
97+
real x(:)
98+
end
99+
95100
end interface
96101

97102
contains
@@ -158,6 +163,14 @@ subroutine bad1(x)
158163
real, intent(in) :: x
159164
end
160165

166+
submodule(m) subm
167+
contains
168+
module subroutine t24(x)
169+
!dir$ ignore_tkr(t) x
170+
real x(:)
171+
end
172+
end
173+
161174
program test
162175

163176
!ERROR: !DIR$ IGNORE_TKR directive must appear in a subroutine or function

0 commit comments

Comments
 (0)