1! RUN: %S/test_errors.sh %s %t %f18 2subroutine s1() 3 ! C701 (R701) The type-param-value for a kind type parameter shall be a 4 ! constant expression. 5 ! 6 ! C702 (R701) A colon shall not be used as a type-param-value except in the 7 ! declaration of an entity that has the POINTER or ALLOCATABLE attribute. 8 ! 9 ! C704 (R703) In a declaration-type-spec, every type-param-value that is 10 ! not a colon or an asterisk shall be a specification expression. 11 ! Section 10.1.11 defines specification expressions 12 ! 13 integer, parameter :: constVal = 1 14 integer :: nonConstVal = 1 15!ERROR: Invalid specification expression: reference to local entity 'nonconstval' 16 character(nonConstVal) :: colonString1 17 character(len=20, kind=constVal + 1) :: constKindString 18 character(len=:, kind=constVal + 1), pointer :: constKindString1 19!ERROR: The type parameter LEN cannot be deferred without the POINTER or ALLOCATABLE attribute 20 character(len=:, kind=constVal + 1) :: constKindString2 21!ERROR: Must be a constant value 22 character(len=20, kind=nonConstVal) :: nonConstKindString 23!ERROR: The type parameter LEN cannot be deferred without the POINTER or ALLOCATABLE attribute 24 character(len=:) :: deferredString 25!ERROR: The type parameter LEN cannot be deferred without the POINTER or ALLOCATABLE attribute 26 character(:) :: colonString2 27 !OK because of the allocatable attribute 28 character(:), allocatable :: colonString3 29 30!ERROR: Must have INTEGER type, but is REAL(4) 31 character(3.5) :: badParamValue 32 33 type derived(typeKind, typeLen) 34 integer, kind :: typeKind 35 integer, len :: typeLen 36 end type derived 37 38 type (derived(constVal, 3)) :: constDerivedKind 39!ERROR: Value of kind type parameter 'typekind' (nonconstval) must be a scalar INTEGER constant 40!ERROR: Invalid specification expression: reference to local entity 'nonconstval' 41 type (derived(nonConstVal, 3)) :: nonConstDerivedKind 42 43 !OK because all type-params are constants 44 type (derived(3, constVal)) :: constDerivedLen 45 46!ERROR: Invalid specification expression: reference to local entity 'nonconstval' 47 type (derived(3, nonConstVal)) :: nonConstDerivedLen 48!ERROR: The value of type parameter 'typelen' cannot be deferred without the POINTER or ALLOCATABLE attribute 49 type (derived(3, :)) :: colonDerivedLen 50!ERROR: The value of type parameter 'typekind' cannot be deferred without the POINTER or ALLOCATABLE attribute 51!ERROR: The value of type parameter 'typelen' cannot be deferred without the POINTER or ALLOCATABLE attribute 52 type (derived( :, :)) :: colonDerivedLen1 53 type (derived( :, :)), pointer :: colonDerivedLen2 54 type (derived(4, :)), pointer :: colonDerivedLen3 55end subroutine s1 56