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
104 lines
5.4 KiB
Fortran
104 lines
5.4 KiB
Fortran
! RUN: %S/test_errors.sh %s %t %f18
|
|
! Check for semantic errors in ALLOCATE statements
|
|
|
|
|
|
subroutine C935(l, ac1, ac2, ac3, dc1, dc2, ec1, ec2, aa, ab, ab2, ea, eb, da, db, whatever, something, something_else)
|
|
! A type-param-value in a type-spec shall be an asterisk if and only if each
|
|
! allocate-object is a dummy argument for which the corresponding type parameter
|
|
! is assumed.
|
|
|
|
type A(la)
|
|
integer, len :: la
|
|
integer vector(la)
|
|
end type
|
|
|
|
type, extends(A) :: B(lb)
|
|
integer, len :: lb
|
|
integer matrix(lb, lb)
|
|
end type
|
|
|
|
type, extends(B) :: C(lc1, lc2, lc3)
|
|
integer, len :: lc1, lc2, lc3
|
|
integer array(lc1, lc2, lc3)
|
|
end type
|
|
|
|
integer l
|
|
character(len=*), pointer :: ac1, ac2(:)
|
|
character*(*), allocatable :: ac3(:)
|
|
character*(:), allocatable :: dc1
|
|
character(len=:), pointer :: dc2(:)
|
|
character(len=l), pointer :: ec1
|
|
character*5, allocatable :: ec2(:)
|
|
|
|
class(A(*)), pointer :: aa
|
|
type(B(* , 5)), allocatable :: ab(:)
|
|
type(B(* , *)), pointer :: ab2(:)
|
|
class(A(l)), allocatable :: ea
|
|
type(B(5 , 5)), pointer :: eb(:)
|
|
class(A(:)), allocatable :: da
|
|
type(B(: , 5)), pointer :: db(:)
|
|
class(*), allocatable :: whatever
|
|
type(C(la=*, lb=:, lc1=*, lc2=5, lc3=*)), pointer :: something(:)
|
|
type(C(la=*, lb=:, lc1=5, lc2=5, lc3=*)), pointer :: something_else(:)
|
|
|
|
! OK
|
|
allocate(character(len=*):: ac1, ac3(3))
|
|
allocate(character*(*):: ac2(5))
|
|
allocate(B(*, 5):: aa, ab(2)) !OK but segfault GCC
|
|
allocate(B(*, *):: ab2(2))
|
|
allocate(C(la=*, lb=10, lc1=*, lc2=5, lc3=*):: something(5))
|
|
allocate(C(la=*, lb=10, lc1=2, lc2=5, lc3=3):: aa)
|
|
allocate(character(5):: whatever)
|
|
|
|
! Not OK
|
|
|
|
! Should be * or no type-spec
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(character(len=5):: ac1)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(character(len=5):: ac2(3), ac3)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(character(len=l):: ac1)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(character(len=l):: ac2(3), ac3)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(A(5):: aa)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(B(5, 5):: ab(5))
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(B(l, 5):: aa, ab(5))
|
|
|
|
! Must not be *
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(character(len=*):: ac1, dc1, ac3(2))
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(character*(*):: dc2(5))
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(character*(*):: ec1)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(character(*):: whatever)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(character(len=*):: ac2(5), ec2(5))
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(A(*):: ea) !segfault gfortran
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(B(*, 5):: eb(2)) !segfault gfortran
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(A(*):: da) !segfault gfortran
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(B(*, 5):: db(2)) !segfault gfortran
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(A(*):: aa, whatever)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(B(*, *):: aa)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(C(la=*, lb=10, lc1=*, lc2=5, lc3=*):: something_else(5))
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(C(la=5, lb=10, lc1=4, lc2=5, lc3=3):: aa)
|
|
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
|
|
allocate(C(la=*, lb=10, lc1=*, lc2=5, lc3=*):: aa)
|
|
end subroutine
|