Skip to content

Commit 8f41431

Browse files
committed
[flang] Disallow BOZ literal constants as arguments of implicit interfaces
Since BOZ literal arguments are typeless, we cannot know how to pass them as actual arguments to procedures with implicit interfaces. This change avoids the problem by emitting an error message in such situations. This change stemmed from the following issue -- flang-compiler#794 Differential Revision: https://reviews.llvm.org/D106831
1 parent c658b47 commit 8f41431

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

flang/lib/Semantics/check-call.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static void CheckImplicitInterfaceArg(
4646
}
4747
}
4848
if (const auto *expr{arg.UnwrapExpr()}) {
49+
if (std::holds_alternative<evaluate::BOZLiteralConstant>(expr->u)) {
50+
messages.Say("BOZ argument requires an explicit interface"_err_en_US);
51+
}
4952
if (auto named{evaluate::ExtractNamedEntity(*expr)}) {
5053
const Symbol &symbol{named->GetLastSymbol()};
5154
if (symbol.Corank() > 0) {

flang/test/Semantics/boz-literal-constants.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,7 @@ subroutine bozchecks
7777
res = MERGE_BITS(B"1101",3,B"1011")
7878

7979
res = REAL(B"1101")
80+
81+
!ERROR: BOZ argument requires an explicit interface
82+
call implictSub(Z'12345')
8083
end subroutine

0 commit comments

Comments
 (0)