Skip to content

Commit 0a145d5

Browse files
author
git apple-llvm automerger
committed
Merge commit 'bf0870d8640d' from llvm.org/master into apple/main
2 parents c98517c + bf0870d commit 0a145d5

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,7 @@ class ResolveNamesVisitor : public virtual ScopeHandler,
13641364
void CheckImport(const SourceName &, const SourceName &);
13651365
void HandleCall(Symbol::Flag, const parser::Call &);
13661366
void HandleProcedureName(Symbol::Flag, const parser::Name &);
1367+
bool CheckImplicitNoneExternal(const SourceName &, const Symbol &);
13671368
bool SetProcFlag(const parser::Name &, Symbol &, Symbol::Flag);
13681369
void ResolveSpecificationParts(ProgramTree &);
13691370
void AddSubpNames(ProgramTree &);
@@ -5853,10 +5854,7 @@ void ResolveNamesVisitor::HandleProcedureName(
58535854
return;
58545855
}
58555856
if (!symbol->attrs().test(Attr::INTRINSIC)) {
5856-
if (isImplicitNoneExternal() && !symbol->attrs().test(Attr::EXTERNAL)) {
5857-
Say(name,
5858-
"'%s' is an external procedure without the EXTERNAL"
5859-
" attribute in a scope with IMPLICIT NONE(EXTERNAL)"_err_en_US);
5857+
if (!CheckImplicitNoneExternal(name.source, *symbol)) {
58605858
return;
58615859
}
58625860
MakeExternal(*symbol);
@@ -5877,6 +5875,7 @@ void ResolveNamesVisitor::HandleProcedureName(
58775875
if (!SetProcFlag(name, *symbol, flag)) {
58785876
return; // reported error
58795877
}
5878+
CheckImplicitNoneExternal(name.source, *symbol);
58805879
if (IsProcedure(*symbol) || symbol->has<DerivedTypeDetails>() ||
58815880
symbol->has<ObjectEntityDetails>() ||
58825881
symbol->has<AssocEntityDetails>()) {
@@ -5895,6 +5894,18 @@ void ResolveNamesVisitor::HandleProcedureName(
58955894
}
58965895
}
58975896

5897+
bool ResolveNamesVisitor::CheckImplicitNoneExternal(
5898+
const SourceName &name, const Symbol &symbol) {
5899+
if (isImplicitNoneExternal() && !symbol.attrs().test(Attr::EXTERNAL) &&
5900+
!symbol.attrs().test(Attr::INTRINSIC) && !symbol.HasExplicitInterface()) {
5901+
Say(name,
5902+
"'%s' is an external procedure without the EXTERNAL"
5903+
" attribute in a scope with IMPLICIT NONE(EXTERNAL)"_err_en_US);
5904+
return false;
5905+
}
5906+
return true;
5907+
}
5908+
58985909
// Variant of HandleProcedureName() for use while skimming the executable
58995910
// part of a subprogram to catch calls to dummy procedures that are part
59005911
// of the subprogram's interface, and to mark as procedures any symbols

flang/test/Semantics/implicit07.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
! RUN: %S/test_errors.sh %s %t %f18
22
implicit none(external)
33
external x
4+
integer :: f, i
45
call x
56
!ERROR: 'y' is an external procedure without the EXTERNAL attribute in a scope with IMPLICIT NONE(EXTERNAL)
67
call y
8+
!ERROR: 'f' is an external procedure without the EXTERNAL attribute in a scope with IMPLICIT NONE(EXTERNAL)
9+
i = f()
710
block
811
!ERROR: 'z' is an external procedure without the EXTERNAL attribute in a scope with IMPLICIT NONE(EXTERNAL)
912
call z

0 commit comments

Comments
 (0)