1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 ! C701 (R701) The type-param-value for a kind type parameter shall be a
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.
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
13 ! 15.4.2.2(4)(c) A procedure must have an explicit interface if it has a
14 ! result that has a nonassumed type parameter value that is not a constant
17 integer, parameter :: constVal
= 1
18 integer :: nonConstVal
= 1
19 !ERROR: Invalid specification expression: reference to local entity 'nonconstval'
20 character(nonConstVal
) :: colonString1
21 character(len
=20, kind
=constVal
+ 1) :: constKindString
22 character(len
=:, kind
=constVal
+ 1), pointer :: constKindString1
23 !ERROR: 'constkindstring2' has a type CHARACTER(KIND=2,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
24 character(len
=:, kind
=constVal
+ 1) :: constKindString2
25 !ERROR: Must be a constant value
26 character(len
=20, kind
=nonConstVal
) :: nonConstKindString
27 !ERROR: 'deferredstring' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
28 character(len
=:) :: deferredString
29 !ERROR: 'colonstring2' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
30 character(:) :: colonString2
31 !OK because of the allocatable attribute
32 character(:), allocatable
:: colonString3
33 !ERROR: 'foo1' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
34 character(:), external :: foo1
35 !ERROR: 'foo2' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
36 procedure(character(:)) :: foo2
39 !ERROR: 'foo3' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
44 !ERROR: Must have INTEGER type, but is REAL(4)
45 character(3.5) :: badParamValue
47 type derived(typeKind
, typeLen
)
48 integer, kind
:: typeKind
49 integer, len
:: typeLen
50 character(typeKind
) :: kindValue
51 character(typeLen
) :: lenValue
54 type (derived(constVal
, 3)) :: constDerivedKind
55 !ERROR: Value of kind type parameter 'typekind' (nonconstval) must be a scalar INTEGER constant
56 !ERROR: Invalid specification expression: reference to local entity 'nonconstval'
57 type (derived(nonConstVal
, 3)) :: nonConstDerivedKind
59 !OK because all type-params are constants
60 type (derived(3, constVal
)) :: constDerivedLen
62 !ERROR: Invalid specification expression: reference to local entity 'nonconstval'
63 type (derived(3, nonConstVal
)) :: nonConstDerivedLen
64 !ERROR: 'colonderivedlen' has a type derived(typekind=3_4,typelen=:) with a deferred type parameter but is neither an allocatable nor an object pointer
65 type (derived(3, :)) :: colonDerivedLen
66 !ERROR: 'colonderivedlen1' has a type derived(typekind=:,typelen=:) with a deferred type parameter but is neither an allocatable nor an object pointer
67 type (derived( :, :)) :: colonDerivedLen1
68 type (derived( :, :)), pointer :: colonDerivedLen2
69 type (derived(4, :)), pointer :: colonDerivedLen3
73 !ERROR: 'f1' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
74 character(:) function f1
78 !ERROR: 'f2' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
82 function f3() result(res
)
83 !ERROR: 'res' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
87 !ERROR: 'f4' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
89 implicit character(:)(f
)
96 Integer,Kind
:: maxlen
97 Character(maxlen
) :: value
101 Print *,Trim(line
%value
)
107 character(n
) function inner1()
115 subroutine s2(dp
,dpp
)
116 !ERROR: 'dp' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
117 procedure(character(:)) :: dp
118 !ERROR: 'dpp' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
119 procedure(character(:)), pointer :: dpp
120 !ERROR: 'pp' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
121 procedure(character(:)), pointer :: pp
122 !ERROR: 'xp' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable nor an object pointer
123 procedure(character(:)) :: xp