Skip to content

Commit d9af9cf

Browse files
authored
[flang] Don't set Subroutine flag on PROCEDURE() pointers (llvm#102011)
External procedures about which no characteristics are known -- from EXTERNAL and PROCEDURE() statements of entities that are never called -- are marked as subroutines. This shouldn't be done for procedure pointers, however. Fixes llvm#101908.
1 parent 28ba8a5 commit d9af9cf

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9235,7 +9235,7 @@ void ResolveNamesVisitor::ResolveSpecificationParts(ProgramTree &node) {
92359235
node.GetKind() == ProgramTree::Kind::Submodule};
92369236
for (auto &pair : *node.scope()) {
92379237
Symbol &symbol{*pair.second};
9238-
if (inModule && symbol.attrs().test(Attr::EXTERNAL) &&
9238+
if (inModule && symbol.attrs().test(Attr::EXTERNAL) && !IsPointer(symbol) &&
92399239
!symbol.test(Symbol::Flag::Function) &&
92409240
!symbol.test(Symbol::Flag::Subroutine)) {
92419241
// in a module, external proc without return type is subroutine

flang/test/Semantics/assign03.f90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
! RUN: %python %S/test_errors.py %s %flang_fc1
22
! Pointer assignment constraints 10.2.2.2 (see also assign02.f90)
33

4+
module m0
5+
procedure(),pointer,save :: p
6+
end
7+
48
module m
59
interface
610
subroutine s(i)
@@ -324,4 +328,10 @@ subroutine s14
324328
!ERROR: Statement function 'sf' may not be the target of a pointer assignment
325329
ptr => sf
326330
end subroutine
331+
332+
subroutine s15
333+
use m0
334+
intrinsic sin
335+
p=>sin ! ok
336+
end
327337
end

0 commit comments

Comments
 (0)