[flang-commits] [PATCH] D155493: [flang] Correct disambiguation of possible statement function definitions

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Jul 17 10:20:03 PDT 2023


klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a project: All.
klausler requested review of this revision.

The statement "A(J) = expr" could be an assignment to an element of an
array A, an assignment to the target of a pointer-valued function A, or
the definition of a new statement function in the local scope named A,
depending on whether it appears in (what might still be) the specification
part of a program or subprogram and what other declarations and definitions
for A might exist in the local scope or have been imported into it.

The standard requires that the name of a statement function appear in
an earlier type declaration statement if it is also the name of an
entity in the enclosing scope.  Some other Fortran compilers mistakenly
enforce that rule in the case of an assignment to the target of a
pointer-valued function in the containing scope, after misinterpreting
the assignment as a new local statement function definition.

This patch cleans up the handling of the various possibilities and
resolves what was a crash in the case of a statement function definition
whose name was the same as that of a procedure in the outer scope whose
result is *not* a pointer.


https://reviews.llvm.org/D155493

Files:
  flang/include/flang/Semantics/tools.h
  flang/lib/Semantics/resolve-names.cpp
  flang/lib/Semantics/tools.cpp
  flang/test/Semantics/resolve08.f90
  flang/test/Semantics/stmt-func02.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155493.541121.patch
Type: text/x-patch
Size: 6252 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230717/65358bc2/attachment-0001.bin>


More information about the flang-commits mailing list