mirror-llvm-project/flang/test/Semantics/bug121973.f90
kwyatt-ext b1b9198709
[flang] Implement check for statement function dummy argument names (#204417)
Implement F2023 19.4.2 conformance check for statement function dummy
argument names

Fixes: #203820 

F2023 19.4.2 permits a statement function dummy argument to share its
name with an **accessible** identifier only when that identifier is a scalar
variable.  Flang previously accepted all such clashes silently.

```fortran
subroutine s
  real :: arr(10)
  real :: ok
  f(arr) = arr + 1   ! error: arr is an array
  h(ok)  = ok + 1    ! ok: scalar variable shadowing is permitted
end subroutine
```

Assisted-by: Claude
2026-07-01 11:35:28 -05:00

10 lines
454 B
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
subroutine s()
real(8) :: a
!ERROR: COMPLEX(KIND=128) is not a supported type
complex(128) :: x
!ERROR: The name 'i' of a statement function dummy argument may not be the same as an accessible name unless that name is a scalar variable
a(i)=a + ((i)+1) + 3.14
!ERROR: 'a' has not been declared as an array or pointer-valued function
a()=z(a * a + n-1 - x) + i((/0,0,0,0,0,0,0,0,0,0/)) + 8
end