[flang-commits] [PATCH] D119274: [flang] catch implicit interface incompatibility with global scope symbol

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Feb 8 12:08:55 PST 2022


jeanPerier created this revision.
jeanPerier added a reviewer: klausler.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a reviewer: sscalpone.
jeanPerier requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Previously, when calling a procedure implicitly for which a global scope
procedure symbol with the same name existed, semantics resolved the
procedure name in the call to the global symbol without checking that
the symbol interface was compatible with the implicit interface of the
call.
This could cause expression rewrite and lowering to later badly process
the implicit call assuming a different result type or an explicit
interface. This could lead to lowering crash in case the actual argument
were incompatible with the dummies from the explicit interface.

Emit errors in the following problematic cases:

- If the result type from the symbol did not match the one from the implicit interface.
- If the symbol requires an explicit interface.

This patch still allows calling an F77 <https://reviews.llvm.org/F77> like procedure with different
actual argument types than the one it was defined with because it is
correctly supported in lowering and is a feature in some program
(it is a pointer cast). The two cases that won't be accepted have
little chance to make much sense. Results returning ABIs may differ
depending on the return types, and function that requires explicit
interface usually requires descriptors or specific processing that
is incompatible with implicit interfaces.

Note that this patch is not making a deep analysis, and it will only
catch mistakes if a global symbol and an implicit interface are
involved. Cases where the user provided a conflicting explicit
interface would still require a pass after name resolution to study
conflicts more deeply. But these cases will not crash lowering or
trigger expression rewrite to do weird things.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119274

Files:
  flang/lib/Semantics/expression.cpp
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/call24.f90
  flang/test/Semantics/resolve89.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119274.406922.patch
Type: text/x-patch
Size: 3987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220208/565de92d/attachment.bin>


More information about the flang-commits mailing list