mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 15:26:41 +00:00

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. Differential Revision: https://reviews.llvm.org/D155493
8 lines
227 B
Fortran
8 lines
227 B
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1
|
|
integer :: g(10)
|
|
f(i) = i + 1 ! statement function
|
|
g(i) = i + 2 ! mis-parsed assignment
|
|
!ERROR: 'h' has not been declared as an array or pointer-valued function
|
|
h(i) = i + 3
|
|
end
|