Skip to content

Commit

Permalink
[flang] Disallow BOZ literal constants as arguments of implicit inter…
Browse files Browse the repository at this point in the history
…faces

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
  • Loading branch information
psteinfeld committed Jul 26, 2021
1 parent c658b47 commit 8f41431
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flang/lib/Semantics/check-call.cpp
Expand Up @@ -46,6 +46,9 @@ static void CheckImplicitInterfaceArg(
}
}
if (const auto *expr{arg.UnwrapExpr()}) {
if (std::holds_alternative<evaluate::BOZLiteralConstant>(expr->u)) {
messages.Say("BOZ argument requires an explicit interface"_err_en_US);
}
if (auto named{evaluate::ExtractNamedEntity(*expr)}) {
const Symbol &symbol{named->GetLastSymbol()};
if (symbol.Corank() > 0) {
Expand Down
3 changes: 3 additions & 0 deletions flang/test/Semantics/boz-literal-constants.f90
Expand Up @@ -77,4 +77,7 @@ subroutine bozchecks
res = MERGE_BITS(B"1101",3,B"1011")

res = REAL(B"1101")

!ERROR: BOZ argument requires an explicit interface
call implictSub(Z'12345')
end subroutine

0 comments on commit 8f41431

Please sign in to comment.