Skip to content

Commit b3b4ea1

Browse files
authored
[flang] Explicit interface externals are constant expressions (#166181)
... but the constant expression test didn't allow for them, so they weren't working in initializers.
1 parent 093f947 commit b3b4ea1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

flang/lib/Evaluate/check-expression.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,11 @@ bool IsInitialProcedureTarget(const semantics::Symbol &symbol) {
379379
common::visitors{
380380
[&](const semantics::SubprogramDetails &subp) {
381381
return !subp.isDummy() && !subp.stmtFunction() &&
382-
symbol.owner().kind() != semantics::Scope::Kind::MainProgram &&
383-
symbol.owner().kind() != semantics::Scope::Kind::Subprogram;
382+
((symbol.owner().kind() !=
383+
semantics::Scope::Kind::MainProgram &&
384+
symbol.owner().kind() !=
385+
semantics::Scope::Kind::Subprogram) ||
386+
ultimate.attrs().test(semantics::Attr::EXTERNAL));
384387
},
385388
[](const semantics::SubprogramNameDetails &x) {
386389
return x.kind() != semantics::SubprogramKind::Internal;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
!RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
2+
!CHECK: TYPE(t) :: x = t(pp=f)
3+
!CHECK-NOT: error:
4+
interface
5+
function f()
6+
end
7+
end interface
8+
type t
9+
procedure(f), nopass, pointer :: pp
10+
end type
11+
type(t) :: x = t(pp=f)
12+
end

0 commit comments

Comments
 (0)