[flang-commits] [PATCH] D157337: [flang] Fix bogus error on recursive ENTRY
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Aug 8 11:26:21 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37d6c1cc7d4d: [flang] Fix bogus error on recursive ENTRY (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157337/new/
https://reviews.llvm.org/D157337
Files:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/global01.f90
Index: flang/test/Semantics/global01.f90
===================================================================
--- flang/test/Semantics/global01.f90
+++ flang/test/Semantics/global01.f90
@@ -21,6 +21,13 @@
integer, intent(in) :: x
end subroutine
+! Regression check: don't emit bogus "Implicit declaration of function 'global7' has a different result type than in previous declaration"
+recursive function global6()
+ integer global6, z, n
+entry global7(n) result(z)
+ if (n > 0) z = global7(n-1)
+end function
+
program test
interface
!WARNING: The global subprogram 'global1' is not compatible with its local procedure declaration (incompatible dummy argument #1: incompatible dummy data object types: INTEGER(4) vs REAL(4))
@@ -40,6 +47,11 @@
pure subroutine global5(x)
integer, intent(in) :: x
end subroutine
+ function global6()
+ integer global6
+ end function
+ function global7(n) result(z)
+ integer n, z
+ end function
end interface
end
-
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -7633,9 +7633,13 @@
static bool IsLocallyImplicitGlobalSymbol(
const Symbol &symbol, const parser::Name &localName) {
- return symbol.owner().IsGlobal() &&
- (!symbol.scope() ||
- !symbol.scope()->sourceRange().Contains(localName.source));
+ if (symbol.owner().IsGlobal()) {
+ const auto *subp{symbol.detailsIf<SubprogramDetails>()};
+ const Scope *scope{
+ subp && subp->entryScope() ? subp->entryScope() : symbol.scope()};
+ return !(scope && scope->sourceRange().Contains(localName.source));
+ }
+ return false;
}
static bool TypesMismatchIfNonNull(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157337.548293.patch
Type: text/x-patch
Size: 1807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230808/3a23b863/attachment-0001.bin>
More information about the flang-commits
mailing list