[flang-commits] [flang] 98d1d52 - [flang] Fix bogus error under IMPLICIT NONE(EXTERNAL)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu May 18 11:53:35 PDT 2023
Author: Peter Klausler
Date: 2023-05-18T11:53:29-07:00
New Revision: 98d1d528d109efd4ed13aaceb6ac31d3f5f24413
URL: https://github.com/llvm/llvm-project/commit/98d1d528d109efd4ed13aaceb6ac31d3f5f24413
DIFF: https://github.com/llvm/llvm-project/commit/98d1d528d109efd4ed13aaceb6ac31d3f5f24413.diff
LOG: [flang] Fix bogus error under IMPLICIT NONE(EXTERNAL)
Don't emit an error message for a possible implicit use of an
external procedure when it is known that the symbol is not
a procedure (e.g., an array).
Fixes https://github.com/llvm/llvm-project/issues/62047
Differential Revision: https://reviews.llvm.org/D150789
Added:
Modified:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/implicit07.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index be9c130ca7e5..fa782f3b414b 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -7164,13 +7164,13 @@ void ResolveNamesVisitor::HandleProcedureName(
symbol = &MakeSymbol(context().globalScope(), name.source, Attrs{});
}
Resolve(name, *symbol);
+ ConvertToProcEntity(*symbol);
if (!symbol->attrs().test(Attr::INTRINSIC)) {
if (CheckImplicitNoneExternal(name.source, *symbol)) {
MakeExternal(*symbol);
}
}
CheckEntryDummyUse(name.source, symbol);
- ConvertToProcEntity(*symbol);
SetProcFlag(name, *symbol, flag);
} else if (CheckUseError(name)) {
// error was reported
@@ -7186,9 +7186,7 @@ void ResolveNamesVisitor::HandleProcedureName(
if (!SetProcFlag(name, *symbol, flag)) {
return; // reported error
}
- if (!symbol->has<GenericDetails>()) {
- CheckImplicitNoneExternal(name.source, *symbol);
- }
+ CheckImplicitNoneExternal(name.source, *symbol);
if (IsProcedure(*symbol) || symbol->has<DerivedTypeDetails>() ||
symbol->has<AssocEntityDetails>()) {
// Symbols with DerivedTypeDetails and AssocEntityDetails are accepted
@@ -7197,7 +7195,7 @@ void ResolveNamesVisitor::HandleProcedureName(
// references that will be fixed later when analyzing expressions.
} else if (symbol->has<ObjectEntityDetails>()) {
// Symbols with ObjectEntityDetails are also accepted because this can be
- // a mis-parsed array references that will be fixed later. Ensure that if
+ // a mis-parsed array reference that will be fixed later. Ensure that if
// this is a symbol from a host procedure, a symbol with HostAssocDetails
// is created for the current scope.
// Operate on non ultimate symbol so that HostAssocDetails are also
@@ -7217,11 +7215,11 @@ void ResolveNamesVisitor::HandleProcedureName(
bool ResolveNamesVisitor::CheckImplicitNoneExternal(
const SourceName &name, const Symbol &symbol) {
- if (isImplicitNoneExternal() && !symbol.attrs().test(Attr::EXTERNAL) &&
+ if (symbol.has<ProcEntityDetails>() && isImplicitNoneExternal() &&
+ !symbol.attrs().test(Attr::EXTERNAL) &&
!symbol.attrs().test(Attr::INTRINSIC) && !symbol.HasExplicitInterface()) {
Say(name,
- "'%s' is an external procedure without the EXTERNAL"
- " attribute in a scope with IMPLICIT NONE(EXTERNAL)"_err_en_US);
+ "'%s' is an external procedure without the EXTERNAL attribute in a scope with IMPLICIT NONE(EXTERNAL)"_err_en_US);
return false;
}
return true;
diff --git a/flang/test/Semantics/implicit07.f90 b/flang/test/Semantics/implicit07.f90
index 30e57e1d55e9..c26b4ac3ccec 100644
--- a/flang/test/Semantics/implicit07.f90
+++ b/flang/test/Semantics/implicit07.f90
@@ -1,7 +1,7 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
implicit none(external)
external x
-integer :: f, i
+integer :: f, i, arr(1) = [0]
call x
!ERROR: 'y' is an external procedure without the EXTERNAL attribute in a scope with IMPLICIT NONE(EXTERNAL)
call y
@@ -11,4 +11,5 @@
!ERROR: 'z' is an external procedure without the EXTERNAL attribute in a scope with IMPLICIT NONE(EXTERNAL)
call z
end block
+print *, arr(1) ! no error
end
More information about the flang-commits
mailing list