There were several different ways of handling the option to f18 to find predefined modules: - test_errors.sh was created by cmake substituting FLANG_INTRINSIC_MODULES_DIR into test_errors.sh.in - some tests used the flang script which has the option built it - some tests used %f18_with_includes which was replaced by the path to f18 plus the -I option - some included -I../../include/flang in their run command To make this more consistent, change %f18 to include the -intrinsic-module-directory option and use it everywhere, including to replace %flang and %f18_with_includes. This requires changing all of the invocations of the test scripts to put %f18 at the end so that it can expand to more than one argument. This eliminates the need to generate test_errors.sh which means we don't need flang/test/Semantics/CMakeLists.txt or the %B substitution. That makes the test_errors.sh command like the others, replacing %B/test/Semantics/test_errors.sh with %S/test_errors.sh. Also remove the OPTIONS: functionality as custom options can be included in the RUN: command. And remove -I/../../include/flang as that is now always included. Differential Revision: https://reviews.llvm.org/D79634
107 lines
2.5 KiB
Fortran
107 lines
2.5 KiB
Fortran
! RUN: %S/test_errors.sh %s %t %f18
|
|
subroutine forall1
|
|
real :: a(9)
|
|
!ERROR: 'i' is already declared in this scoping unit
|
|
!ERROR: Cannot redefine FORALL variable 'i'
|
|
forall (i=1:8, i=1:9) a(i) = i
|
|
!ERROR: 'i' is already declared in this scoping unit
|
|
!ERROR: Cannot redefine FORALL variable 'i'
|
|
forall (i=1:8, i=1:9)
|
|
a(i) = i
|
|
end forall
|
|
forall (j=1:8)
|
|
!ERROR: 'j' is already declared in this scoping unit
|
|
!ERROR: Cannot redefine FORALL variable 'j'
|
|
forall (j=1:9)
|
|
end forall
|
|
end forall
|
|
end
|
|
|
|
subroutine forall2
|
|
integer, pointer :: a(:)
|
|
integer, target :: b(10,10)
|
|
forall (i=1:10)
|
|
!ERROR: Impure procedure 'f_impure' may not be referenced in a FORALL
|
|
a(f_impure(i):) => b(i,:)
|
|
end forall
|
|
!ERROR: FORALL mask expression may not reference impure procedure 'f_impure'
|
|
forall (j=1:10, f_impure(1)>2)
|
|
end forall
|
|
contains
|
|
impure integer function f_impure(i)
|
|
f_impure = i
|
|
end
|
|
end
|
|
|
|
subroutine forall3
|
|
real :: x
|
|
forall(i=1:10)
|
|
!ERROR: Cannot redefine FORALL variable 'i'
|
|
i = 1
|
|
end forall
|
|
forall(i=1:10)
|
|
forall(j=1:10)
|
|
!ERROR: Cannot redefine FORALL variable 'i'
|
|
i = 1
|
|
end forall
|
|
end forall
|
|
!ERROR: Cannot redefine FORALL variable 'i'
|
|
forall(i=1:10) i = 1
|
|
end
|
|
|
|
subroutine forall4
|
|
integer, parameter :: zero = 0
|
|
integer :: a(10)
|
|
|
|
!ERROR: FORALL limit expression may not reference index variable 'i'
|
|
forall(i=1:i)
|
|
a(i) = i
|
|
end forall
|
|
!ERROR: FORALL step expression may not reference index variable 'i'
|
|
forall(i=1:10:i)
|
|
a(i) = i
|
|
end forall
|
|
!ERROR: FORALL step expression may not be zero
|
|
forall(i=1:10:zero)
|
|
a(i) = i
|
|
end forall
|
|
|
|
!ERROR: FORALL limit expression may not reference index variable 'i'
|
|
forall(i=1:i) a(i) = i
|
|
!ERROR: FORALL step expression may not reference index variable 'i'
|
|
forall(i=1:10:i) a(i) = i
|
|
!ERROR: FORALL step expression may not be zero
|
|
forall(i=1:10:zero) a(i) = i
|
|
end
|
|
|
|
! Note: this gets warnings but not errors
|
|
subroutine forall5
|
|
real, target :: x(10), y(10)
|
|
forall(i=1:10)
|
|
x(i) = y(i)
|
|
end forall
|
|
forall(i=1:10)
|
|
x = y ! warning: i not used on LHS
|
|
forall(j=1:10)
|
|
x(i) = y(i) ! warning: j not used on LHS
|
|
x(j) = y(j) ! warning: i not used on LHS
|
|
endforall
|
|
endforall
|
|
do concurrent(i=1:10)
|
|
x = y
|
|
forall(i=1:10) x = y
|
|
end do
|
|
end
|
|
|
|
subroutine forall6
|
|
type t
|
|
real, pointer :: p
|
|
end type
|
|
type(t) :: a(10)
|
|
real, target :: b(10)
|
|
forall(i=1:10)
|
|
a(i)%p => b(i)
|
|
a(1)%p => b(i) ! warning: i not used on LHS
|
|
end forall
|
|
end
|