llvm-project/flang/test/Semantics/modifiable01.f90
Andrzej Warzynski e7be90bd27 [flang] Update the regression tests to use the new driver when enabled
This patch updates most of the remaining regression tests (~400) to use
`flang-new` rather then `f18` when `FLANG_BUILD_NEW_DRIVER` is set.
This allows us to share more Flang regression tests between `f18` and
`flang-new`. A handful of tests have not been ported yet - these are
currently either failing or not supported by the new driver.

Summary of changes:
  * RUN lines in tests are updated to use `%flang_fc1` instead of `%f18`
  * option spellings in tests are updated to forms accepted by both `f18` and
    `flang-new`
  * variables in Bash scripts are renamed (e.g. F18 --> FLANG_FC1)
The updated tests will now be run with the new driver, `flang-new`,
whenever it is enabled (i.e when `FLANG_BUILD_NEW_DRIVER` is set).

Although this patch touches many files, vast majority of the changes are
automatic:
```
grep -IEZlr "%f18" flang/test/ | xargs -0 -l sed -i 's/%f18/%flang_fc1/g
```

Differential Revision: https://reviews.llvm.org/D100309
2021-04-15 08:52:23 +00:00

71 lines
2.0 KiB
Fortran

! RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s
! Test WhyNotModifiable() explanations
module prot
real, protected :: prot
type :: ptype
real, pointer :: ptr
real :: x
end type
type(ptype), protected :: protptr
contains
subroutine ok
prot = 0. ! ok
end subroutine
end module
module m
use iso_fortran_env
use prot
type :: t1
type(lock_type) :: lock
end type
type :: t2
type(t1) :: x1
real :: x2
end type
type(t2) :: t2static
character(*), parameter :: internal = '0'
contains
subroutine test1(dummy)
real :: arr(2)
integer, parameter :: j3 = 666
type(ptype), intent(in) :: dummy
type(t2) :: t2var
associate (a => 3+4)
!CHECK: error: Input variable 'a' must be definable
!CHECK: 'a' is construct associated with an expression
read(internal,*) a
end associate
associate (a => arr([1])) ! vector subscript
!CHECK: error: Input variable 'a' must be definable
!CHECK: 'a' is construct associated with an expression
read(internal,*) a
end associate
associate (a => arr(2:1:-1))
read(internal,*) a ! ok
end associate
!CHECK: error: Input variable 'j3' must be definable
!CHECK: '666_4' is not a variable
read(internal,*) j3
!CHECK: error: Left-hand side of assignment is not modifiable
!CHECK: 't2var' is an entity with either an EVENT_TYPE or LOCK_TYPE
t2var = t2static
t2var%x2 = 0. ! ok
!CHECK: error: Left-hand side of assignment is not modifiable
!CHECK: 'prot' is protected in this scope
prot = 0.
protptr%ptr = 0. ! ok
!CHECK: error: Left-hand side of assignment is not modifiable
!CHECK: 'dummy' is an INTENT(IN) dummy argument
dummy%x = 0.
dummy%ptr = 0. ! ok
end subroutine
pure subroutine test2(ptr)
integer, pointer, intent(in) :: ptr
!CHECK: error: Input variable 'ptr' must be definable
!CHECK: 'ptr' is externally visible and referenced in a pure procedure
read(internal,*) ptr
end subroutine
end module